Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace JsTypeError with just JsError #74

Closed
dherman opened this issue Apr 23, 2016 · 0 comments
Closed

replace JsTypeError with just JsError #74

dherman opened this issue Apr 23, 2016 · 0 comments

Comments

@dherman
Copy link
Collaborator

dherman commented Apr 23, 2016

V8 doesn't have brand checks for the different subclasses of Error; there's only one brand that can be checked with v8::IsNativeError. So instead of JsTypeError, JsReferenceError, etc, there should just be one JsError that has factory methods for constructing the different subclasses, like JsError::type_error() and JsError::throw_type_error(), JsError::reference_error() and JsError::throw_reference_error(), etc.

Affects: #65, #66, #67, #68.

dherman pushed a commit that referenced this issue Apr 25, 2016
There are only a fixed set of Error classes, because even though V8 offers the `Error.captureStackTrace` API for decorating an object with Error-like properties, `IsNativeError` still reports `false` for such an object. So there's really no way with V8 to create custom subclasses of `Error`.

Since there's only a fixed set (and their constructors all have the same signature), they're enumerated in a concise `enum` and passed to `JsError::new` and `JsError::throw`.
@dherman dherman closed this as completed Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant