-
Notifications
You must be signed in to change notification settings - Fork 29
Add panic function #72
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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c06a60
feat(error): add panic/Error.panic
glennsl cb56e44
test(error): test panic
glennsl 56886f0
docs(changelog): update changelog for panic/Error.panic
glennsl 7439a31
docs(changelog): adjust panic entry after splitting PR
glennsl 3b12085
Merge branch 'main' into feat/panic
glennsl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -35,3 +35,5 @@ module URIError = { | |
} | ||
|
||
external raise: t => 'a = "%raise" | ||
|
||
let panic = msg => make(j`Panic! $msg`)->raise |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
import * as Test from "./Test.mjs"; | ||
import * as Js_exn from "rescript/lib/es6/js_exn.js"; | ||
import * as RescriptCore from "../src/RescriptCore.mjs"; | ||
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; | ||
|
||
function panicTest(param) { | ||
var caught; | ||
try { | ||
caught = RescriptCore.panic("uh oh"); | ||
} | ||
catch (raw_err){ | ||
var err = Caml_js_exceptions.internalToOCamlException(raw_err); | ||
if (err.RE_EXN_ID === Js_exn.$$Error) { | ||
caught = err._1.message; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
Test.run([ | ||
[ | ||
"ErrorTests.res", | ||
8, | ||
22, | ||
43 | ||
], | ||
"Should resolve test" | ||
], caught, (function (prim0, prim1) { | ||
return prim0 === prim1; | ||
}), "Panic! uh oh"); | ||
} | ||
|
||
panicTest(undefined); | ||
|
||
export { | ||
panicTest , | ||
} | ||
/* Not a pure module */ |
This file contains hidden or 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,11 @@ | ||
open RescriptCore | ||
|
||
let panicTest = () => { | ||
let caught = try panic("uh oh") catch { | ||
| Exn.Error(err) => Error.message(err) | ||
} | ||
|
||
Test.run(__POS_OF__("Should resolve test"), caught, \"==", Some("Panic! uh oh")) | ||
} | ||
|
||
panicTest() |
This file contains hidden or 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,35 @@ | ||
// Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
||
import * as ErrorTests from "./ErrorTests.mjs"; | ||
import * as PromiseTest from "./PromiseTest.mjs"; | ||
|
||
var TestError = PromiseTest.TestError; | ||
|
||
var fail = PromiseTest.fail; | ||
|
||
var equal = PromiseTest.equal; | ||
|
||
var Creation = PromiseTest.Creation; | ||
|
||
var ThenChaining = PromiseTest.ThenChaining; | ||
|
||
var Rejection = PromiseTest.Rejection; | ||
|
||
var Catching = PromiseTest.Catching; | ||
|
||
var Concurrently = PromiseTest.Concurrently; | ||
|
||
var panicTest = ErrorTests.panicTest; | ||
|
||
export { | ||
TestError , | ||
fail , | ||
equal , | ||
Creation , | ||
ThenChaining , | ||
Rejection , | ||
Catching , | ||
Concurrently , | ||
panicTest , | ||
} | ||
/* ErrorTests Not a pure module */ |
This file contains hidden or 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,2 @@ | ||
include PromiseTest | ||
include ErrorTests |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.