Skip to content

Commit e18406c

Browse files
authored
Document the new exception API (#1046)
* Document the new API around exceptions * update other pages with the new exception API * improve wording
1 parent 3ad8c92 commit e18406c

File tree

6 files changed

+146
-130
lines changed

6 files changed

+146
-130
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
}

0 commit comments

Comments
 (0)