mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support optional message for dataclone error (#36308)
- [x] our [DataClone error](d733abfca0/components/script/dom/bindings/error.rs (L80)
) needs to support an optional message - [x] we need to add support to our DOMException implementation to allow an optional message to replace the default message - [x] we need to create a new struct used by both StructuredDataReader and StructuredDataWriter for storing the error message in the report_error_callback - [x] report_error_callback needs to cast the closure pointer to the new struct - [x] the code that [throws a DataClone error](5d1c64dba9/components/script/dom/bindings/structuredclone.rs (L542)
) needs to use the stored error message if it's available Testing: *Describe how this pull request is tested or why it doesn't require tests* Fixes: #36191 --------- Signed-off-by: jerensl <54782057+jerensl@users.noreply.github.com>
This commit is contained in:
parent
740a94ef20
commit
d5284dfad9
7 changed files with 61 additions and 10 deletions
|
@ -70,7 +70,22 @@ pub(crate) fn throw_dom_exception(
|
|||
Error::Abort => DOMErrorName::AbortError,
|
||||
Error::Timeout => DOMErrorName::TimeoutError,
|
||||
Error::InvalidNodeType => DOMErrorName::InvalidNodeTypeError,
|
||||
Error::DataClone => DOMErrorName::DataCloneError,
|
||||
Error::DataClone(message) => match message {
|
||||
Some(custom_message) => unsafe {
|
||||
assert!(!JS_IsExceptionPending(*cx));
|
||||
let exception = DOMException::new_with_custom_message(
|
||||
global,
|
||||
DOMErrorName::DataCloneError,
|
||||
custom_message,
|
||||
can_gc,
|
||||
);
|
||||
rooted!(in(*cx) let mut thrown = UndefinedValue());
|
||||
exception.to_jsval(*cx, thrown.handle_mut());
|
||||
JS_SetPendingException(*cx, thrown.handle(), ExceptionStackBehavior::Capture);
|
||||
return;
|
||||
},
|
||||
None => DOMErrorName::DataCloneError,
|
||||
},
|
||||
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
|
||||
Error::QuotaExceeded => DOMErrorName::QuotaExceededError,
|
||||
Error::TypeMismatch => DOMErrorName::TypeMismatchError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue