Skip to content

Commit 00eec8c

Browse files
nojaftsnobip
andauthored
Update markdown-pages/blog/release-12-0-0.mdx
Co-authored-by: Paul Tsnobiladzé <paul.tsnobiladze@gmail.com>
1 parent 113b84f commit 00eec8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

markdown-pages/blog/release-12-0-0.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ We’ve renamed JS errors to `JsError.t` to better distinguish them from the `Re
5353
```res
5454
let foo = switch myUnsafeJsResult() {
5555
| exception Exn.Error(e) => Error(e->Error.message)
56-
// ☝️ this will crash if `e` is undefined or null,
57-
// or return undefined if `e` has no `message` property
56+
// ☝️ this will crash if `e` is undefined or null
5857
| myRes => Ok(myRes)
5958
}
6059
```
@@ -63,7 +62,8 @@ Additionally, the coexistence of `Result.Error` and the `Error` module caused co
6362
The new recommended pattern is:
6463
```res
6564
let foo = switch myUnsafeJsResult() {
66-
| exception JsExn(e) => Error(e->JsExn.message->Option.getOr("[no message]"))
65+
| exception JsExn(e) => Error(e->JsExn.message))
66+
// ☝️ this is now safe even `e` is undefined or null
6767
| myRes => Ok(myRes)
6868
}
6969
```

0 commit comments

Comments
 (0)