diff --git a/CHANGELOG.md b/CHANGELOG.md index 070d0df456..4ba7e01aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :bug: Bug fix - Fix `Error.fromException`. https://github.com/rescript-lang/rescript/pull/7364 +- Fix signature of `throw`. https://github.com/rescript-lang/rescript/pull/7365 #### :house: Internal diff --git a/runtime/Pervasives.res b/runtime/Pervasives.res index 8ad37dc83e..0f73f5cc08 100644 --- a/runtime/Pervasives.res +++ b/runtime/Pervasives.res @@ -23,16 +23,18 @@ Raises the given exception, terminating execution unless caught by a surrounding ## Examples ```rescript -let error = Error.make("Everything is upside down.") +exception MyException(string) -if 5 > 10 { - throw(error) -} else { - Console.log("Phew, sanity still rules.") +let result = try { + throw(MyException("Out of milk")) +} catch { +| MyException(message) => "Caught exception: " ++ message } + +assertEqual(result, "Caught exception: Out of milk") ``` */ -external throw: Stdlib_Error.t => 'a = "%raise" +external throw: exn => 'a = "%raise" /* Composition operators */