We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 64f449d commit cf91c9eCopy full SHA for cf91c9e
src/Core__Nullable.mjs
@@ -9,7 +9,19 @@ function fromOption(option) {
9
10
}
11
12
+function getExn(value) {
13
+ if (!(value == null)) {
14
+ return value;
15
+ }
16
+ throw {
17
+ RE_EXN_ID: "Invalid_argument",
18
+ _1: "Nullable.getExn: value is null or undefined",
19
+ Error: new Error()
20
+ };
21
+}
22
+
23
export {
24
fromOption ,
25
+ getExn ,
26
27
/* No side effect */
src/Core__Nullable.res
@@ -13,3 +13,9 @@ let fromOption: option<'a> => t<'a> = option =>
| Some(x) => make(x)
| None => undefined
+let getExn: t<'a> => 'a = value =>
+ switch value->toOption {
+ | Some(x) => x
+ | None => raise(Invalid_argument("Nullable.getExn: value is null or undefined"))
0 commit comments