-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stdlib): Add
Exception.toString
(#2143)
- Loading branch information
1 parent
f97c011
commit 0894dc5
Showing
12 changed files
with
237 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module ExceptionTest | ||
|
||
from "exception" include Exception | ||
|
||
exception Test1 | ||
exception Test2(String) | ||
// Exception.toString | ||
assert Exception.toString(Failure("Test")) == "Failure: Test" | ||
assert Exception.toString(Test1) == "Test1" | ||
assert Exception.toString(Test2("Test")) == "Test2(\"Test\")" | ||
|
||
// Exception.registerPrinter | ||
let printer = e => { | ||
match (e) { | ||
Test1 => Some("Test1: This is a test"), | ||
Test2(s) => Some("Test2"), | ||
_ => None, | ||
} | ||
} | ||
Exception.registerPrinter(printer) | ||
assert Exception.toString(Test1) == "Test1: This is a test" | ||
assert Exception.toString(Test2("Test")) == "Test2" |
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
Oops, something went wrong.