Make all errors extend Object

Part of #670
This commit is contained in:
Matt Kraai 2018-08-17 13:10:11 -07:00
parent 687412ec50
commit bec3178e3c
6 changed files with 15 additions and 5 deletions

View File

@ -2092,7 +2092,7 @@ extern {
/// or range of allowed values.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError
#[wasm_bindgen(extends = Error)]
#[wasm_bindgen(extends = Error, extends = Object)]
#[derive(Clone, Debug)]
pub type RangeError;
@ -2111,7 +2111,7 @@ extern {
/// variable is referenced.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
#[wasm_bindgen(extends = Error)]
#[wasm_bindgen(extends = Error, extends = Object)]
#[derive(Clone, Debug)]
pub type ReferenceError;
@ -2505,7 +2505,7 @@ extern {
/// parsing code.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError
#[wasm_bindgen(extends = Error)]
#[wasm_bindgen(extends = Error, extends = Object)]
#[derive(Clone, Debug)]
pub type SyntaxError;
@ -2525,7 +2525,7 @@ extern {
/// expected type.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
#[wasm_bindgen(extends = Error)]
#[wasm_bindgen(extends = Error, extends = Object)]
#[derive(Clone, Debug)]
pub type TypeError;
@ -2758,7 +2758,7 @@ extern {
/// function was used in a wrong way.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
#[wasm_bindgen(extends = Error, js_name = URIError)]
#[wasm_bindgen(extends = Error, extends = Object, js_name = URIError)]
#[derive(Clone, Debug)]
pub type UriError;

View File

@ -9,6 +9,8 @@ fn range_error() {
assert!(error.is_instance_of::<RangeError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "out of range yo");

View File

@ -9,6 +9,8 @@ fn reference_error() {
assert!(error.is_instance_of::<ReferenceError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "bad reference, fool");

View File

@ -9,6 +9,8 @@ fn syntax_error() {
assert!(error.is_instance_of::<SyntaxError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");

View File

@ -9,6 +9,8 @@ fn type_error() {
assert!(error.is_instance_of::<TypeError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");

View File

@ -9,6 +9,8 @@ fn uri_error() {
assert!(error.is_instance_of::<UriError>());
assert!(error.is_instance_of::<Error>());
assert!(error.is_instance_of::<Object>());
let _: &Error = error.as_ref();
let _: &Object = error.as_ref();
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");