forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Format non-error exceptions (denoland#14604)
This commit adds "Deno.core.setFormatExceptionCallback" which can be used to provide custom formatting for errors. It is useful in cases when user throws something that is non-Error (eg. a string, plain object, etc).
- Loading branch information
Showing
16 changed files
with
177 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
throw {}; | ||
throw { foo: "bar" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[WILDCARD]error: Uncaught #<Object> | ||
[WILDCARD]error: Uncaught { foo: "bar" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
running 6 tests from [WILDCARD]/non_error_thrown.ts | ||
foo ... FAILED ([WILDCARD]) | ||
bar ... FAILED ([WILDCARD]) | ||
baz ... FAILED ([WILDCARD]) | ||
qux ... FAILED ([WILDCARD]) | ||
quux ... FAILED ([WILDCARD]) | ||
quuz ... FAILED ([WILDCARD]) | ||
|
||
ERRORS | ||
|
||
foo => [WILDCARD]/non_error_thrown.ts:1:6 | ||
error: undefined | ||
|
||
bar => [WILDCARD]/non_error_thrown.ts:5:6 | ||
error: null | ||
|
||
baz => [WILDCARD]/non_error_thrown.ts:9:6 | ||
error: 123 | ||
|
||
qux => [WILDCARD]/non_error_thrown.ts:13:6 | ||
error: "Hello, world!" | ||
|
||
quux => [WILDCARD]/non_error_thrown.ts:17:6 | ||
error: [ 1, 2, 3 ] | ||
|
||
quuz => [WILDCARD]/non_error_thrown.ts:21:6 | ||
error: { a: "Hello, world!", b: [ 1, 2, 3 ] } | ||
|
||
FAILURES | ||
|
||
foo => [WILDCARD]/non_error_thrown.ts:1:6 | ||
bar => [WILDCARD]/non_error_thrown.ts:5:6 | ||
baz => [WILDCARD]/non_error_thrown.ts:9:6 | ||
qux => [WILDCARD]/non_error_thrown.ts:13:6 | ||
quux => [WILDCARD]/non_error_thrown.ts:17:6 | ||
quuz => [WILDCARD]/non_error_thrown.ts:21:6 | ||
|
||
test result: FAILED. 0 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) | ||
|
||
error: Test failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Deno.test("foo", () => { | ||
throw undefined; | ||
}); | ||
|
||
Deno.test("bar", () => { | ||
throw null; | ||
}); | ||
|
||
Deno.test("baz", () => { | ||
throw 123; | ||
}); | ||
|
||
Deno.test("qux", () => { | ||
throw "Hello, world!"; | ||
}); | ||
|
||
Deno.test("quux", () => { | ||
throw [1, 2, 3]; | ||
}); | ||
|
||
Deno.test("quuz", () => { | ||
throw { a: "Hello, world!", b: [1, 2, 3] }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2322,5 +2322,6 @@ | |
inspect, | ||
wrapConsole, | ||
createFilteredInspectProxy, | ||
quoteString, | ||
}; | ||
})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters