Skip to content

Commit cfcd293

Browse files
cknittfhammerschmidt
authored andcommitted
Fix Error.fromException (#7364)
1 parent 665a645 commit cfcd293

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
1313
# 12.0.0-alpha.11 (Unreleased)
1414

15+
#### :bug: Bug fix
16+
17+
- Fix `Error.fromException`. https://github.com/rescript-lang/rescript/pull/7364
18+
19+
# 12.0.0-alpha.10
20+
1521
#### :rocket: New Feature
1622

1723
- Add `Dict.has` and double `Dict.forEachWithKey`/`Dict.mapValues` performance. https://github.com/rescript-lang/rescript/pull/7316

lib/es6/Stdlib_Error.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22

3+
import * as Stdlib_Exn from "./Stdlib_Exn.js";
34
import * as Primitive_option from "./Primitive_option.js";
45

56
function fromException(exn) {
6-
if (exn.TAG === "Ok") {
7-
return;
8-
} else {
9-
return Primitive_option.some(exn._0);
7+
if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) {
8+
return Primitive_option.some(exn._1);
109
}
10+
1111
}
1212

1313
let $$EvalError = {};

lib/js/Stdlib_Error.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22

3+
let Stdlib_Exn = require("./Stdlib_Exn.js");
34
let Primitive_option = require("./Primitive_option.js");
45

56
function fromException(exn) {
6-
if (exn.TAG === "Ok") {
7-
return;
8-
} else {
9-
return Primitive_option.some(exn._0);
7+
if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) {
8+
return Primitive_option.some(exn._1);
109
}
10+
1111
}
1212

1313
let $$EvalError = {};

runtime/Stdlib_Error.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type t = Stdlib_Exn.t
22

33
let fromException: exn => option<t> = exn =>
44
switch Obj.magic(exn) {
5-
| Error(t) => Some(t)
5+
| Stdlib_Exn.Error(t) => Some(t)
66
| _ => None
77
}
88
external toException: t => exn = "%identity"

0 commit comments

Comments
 (0)