Skip to content

Commit 2052653

Browse files
committed
update other pages with the new exception API
1 parent 938d9e2 commit 2052653

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

pages/docs/manual/v12.0.0/async-await.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ You may use `try / catch` or `switch` to handle exceptions during async executio
130130
```res
131131
// For simulation purposes
132132
let authenticate = async () => {
133-
raise(Exn.raiseRangeError("Authentication failed."))
133+
JsError.RangeError.throwWithMessage("Authentication failed.")
134134
}
135135
136136
let checkAuth = async () => {
137137
try {
138138
await authenticate()
139139
} catch {
140-
| Exn.Error(e) =>
141-
switch Exn.message(e) {
140+
| JsExn(e) =>
141+
switch JsExn.message(e) {
142142
| Some(msg) => Console.log("JS error thrown: " ++ msg)
143143
| None => Console.log("Some other exception has been thrown")
144144
}
@@ -152,14 +152,14 @@ You may unify error and value handling in a single switch as well:
152152

153153
```res
154154
let authenticate = async () => {
155-
raise(Exn.raiseRangeError("Authentication failed."))
155+
JsError.RangeError.throwWithMessage("Authentication failed.")
156156
}
157157
158158
let checkAuth = async () => {
159159
switch await authenticate() {
160160
| _ => Console.log("ok")
161-
| exception Exn.Error(e) =>
162-
switch Exn.message(e) {
161+
| exception JsExn(e) =>
162+
switch JsExn.message(e) {
163163
| Some(msg) => Console.log("JS error thrown: " ++ msg)
164164
| None => Console.log("Some other exception has been thrown")
165165
}

pages/docs/manual/v12.0.0/function.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ Both JS exceptions and exceptions defined in ReScript can be caught. The compile
446446
```res example
447447
exception SomeReScriptException
448448
449-
let somethingThatMightThrow = async () => raise(SomeReScriptException)
449+
let somethingThatMightThrow = async () => throw(SomeReScriptException)
450450
451451
let someAsyncFn = async () => {
452452
switch await somethingThatMightThrow() {

pages/docs/manual/v12.0.0/lazy-values.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The first time `Lazy.get` is called, the expensive computation happens and the r
6262

6363
## Exception Handling
6464

65-
For completeness' sake, our files read example might raise an exception because of `readdirSync`. Here's how you'd handle it:
65+
For completeness' sake, our files read example might throw an exception because of `readdirSync`. Here's how you'd handle it:
6666

6767
<CodeTab labels={["ReScript", "JS Output"]}>
6868

pages/docs/manual/v12.0.0/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ canonical: "/docs/manual/v12.0.0/overview"
187187

188188
| JavaScript | ReScript |
189189
| ----------------------------------------- | -------------------------------------------- |
190-
| `throw new SomeError(...)` | `raise(SomeError(...))` |
191-
| `try {a} catch (err) {...} finally {...}` | `try a catch { \| SomeError(err) => ...}` \* |
190+
| `throw new SomeError(...)` | `throw(SomeException(...))` |
191+
| `try {a} catch (err) {...} finally {...}` | `try a catch { \| SomeException(err) => ...}` \* |
192192

193193
\* No finally.
194194

pages/docs/manual/v12.0.0/scoped-polymorphic-types.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ Scoped polymorphic types work only when they are directly applied to let-binding
9292
```res
9393
exception Abort
9494
95-
let testExn: 'a. unit => 'a = () => raise(Abort) // Works!
95+
let testExn: 'a. unit => 'a = () => throw(Abort) // Works!
9696
97-
let testExn2 = (): 'a. 'a = raise(Abort) // Syntax error!
97+
let testExn2 = (): 'a. 'a = throw(Abort) // Syntax error!
9898
type fn = 'a. 'a => unit // Syntax error!
9999
```
100100

0 commit comments

Comments
 (0)