Skip to content

Make JSError conform to JSBridgedClass #86

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

Merged
merged 2 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,12 @@ try test("Promise") {

try test("Error") {
let message = "test error"
let expectedDescription = "Error: test error"
let error = JSError(message: message)
try expectEqual(error.name, "Error")
try expectEqual(error.message, message)
try expectEqual(error.description, "Error: test error")
try expectEqual(error.description, expectedDescription)
try expectEqual(error.stack?.isEmpty, false)
try expectEqual(JSError(from: .string("error"))?.description, nil)
try expectEqual(JSError(from: .object(error.jsObject))?.description, expectedDescription)
}
2 changes: 1 addition & 1 deletion Sources/JavaScriptKit/BasicObjects/JSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) that
exposes its properties in a type-safe way.
*/
public final class JSError: Error, JSValueConvertible {
public final class JSError: Error, JSBridgedClass {
/// The constructor function used to create new JavaScript `Error` objects.
public static let constructor = JSObject.global.Error.function!

Expand Down