mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Add message to NotFoundError (#39394)
Adding an optional message to be attached to a NotFoundError. Testing: Just a refactor Part of #39053 --------- Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
This commit is contained in:
parent
ffdb7d3663
commit
9713bb9e1b
18 changed files with 37 additions and 38 deletions
|
@ -99,9 +99,18 @@ pub(crate) fn create_dom_exception(
|
|||
result: Error,
|
||||
can_gc: CanGc,
|
||||
) -> Result<DomRoot<DOMException>, JsEngineError> {
|
||||
let new_custom_exception = |error_name, message| {
|
||||
Ok(DOMException::new_with_custom_message(
|
||||
global, error_name, message, can_gc,
|
||||
))
|
||||
};
|
||||
|
||||
let code = match result {
|
||||
Error::IndexSize => DOMErrorName::IndexSizeError,
|
||||
Error::NotFound => DOMErrorName::NotFoundError,
|
||||
Error::NotFound(Some(custom_message)) => {
|
||||
return new_custom_exception(DOMErrorName::NotFoundError, custom_message);
|
||||
},
|
||||
Error::NotFound(None) => DOMErrorName::NotFoundError,
|
||||
Error::HierarchyRequest => DOMErrorName::HierarchyRequestError,
|
||||
Error::WrongDocument => DOMErrorName::WrongDocumentError,
|
||||
Error::InvalidCharacter => DOMErrorName::InvalidCharacterError,
|
||||
|
@ -109,12 +118,7 @@ pub(crate) fn create_dom_exception(
|
|||
Error::InUseAttribute => DOMErrorName::InUseAttributeError,
|
||||
Error::InvalidState => DOMErrorName::InvalidStateError,
|
||||
Error::Syntax(Some(custom_message)) => {
|
||||
return Ok(DOMException::new_with_custom_message(
|
||||
global,
|
||||
DOMErrorName::SyntaxError,
|
||||
custom_message,
|
||||
can_gc,
|
||||
));
|
||||
return new_custom_exception(DOMErrorName::SyntaxError, custom_message);
|
||||
},
|
||||
Error::Syntax(None) => DOMErrorName::SyntaxError,
|
||||
Error::Namespace => DOMErrorName::NamespaceError,
|
||||
|
@ -125,12 +129,7 @@ pub(crate) fn create_dom_exception(
|
|||
Error::Timeout => DOMErrorName::TimeoutError,
|
||||
Error::InvalidNodeType => DOMErrorName::InvalidNodeTypeError,
|
||||
Error::DataClone(Some(custom_message)) => {
|
||||
return Ok(DOMException::new_with_custom_message(
|
||||
global,
|
||||
DOMErrorName::DataCloneError,
|
||||
custom_message,
|
||||
can_gc,
|
||||
));
|
||||
return new_custom_exception(DOMErrorName::DataCloneError, custom_message);
|
||||
},
|
||||
Error::DataClone(None) => DOMErrorName::DataCloneError,
|
||||
Error::Data => DOMErrorName::DataError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue