diff --git a/lib/es6/Js_exn.js b/lib/es6/Exn.js similarity index 100% rename from lib/es6/Js_exn.js rename to lib/es6/Exn.js diff --git a/lib/js/Js_exn.js b/lib/js/Exn.js similarity index 100% rename from lib/js/Js_exn.js rename to lib/js/Exn.js diff --git a/packages/artifacts.txt b/packages/artifacts.txt index d8838d4f3f..f2dd3f6c11 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -83,6 +83,7 @@ lib/es6/Dom.js lib/es6/Dom_storage.js lib/es6/Dom_storage2.js lib/es6/Error.js +lib/es6/Exn.js lib/es6/Float.js lib/es6/Float32Array.js lib/es6/Float64Array.js @@ -114,7 +115,6 @@ lib/es6/Js_blob.js lib/es6/Js_console.js lib/es6/Js_date.js lib/es6/Js_dict.js -lib/es6/Js_exn.js lib/es6/Js_extern.js lib/es6/Js_file.js lib/es6/Js_float.js @@ -253,6 +253,7 @@ lib/js/Dom.js lib/js/Dom_storage.js lib/js/Dom_storage2.js lib/js/Error.js +lib/js/Exn.js lib/js/Float.js lib/js/Float32Array.js lib/js/Float64Array.js @@ -284,7 +285,6 @@ lib/js/Js_blob.js lib/js/Js_console.js lib/js/Js_date.js lib/js/Js_dict.js -lib/js/Js_exn.js lib/js/Js_extern.js lib/js/Js_file.js lib/js/Js_float.js @@ -687,6 +687,12 @@ lib/ocaml/Error.cmt lib/ocaml/Error.cmti lib/ocaml/Error.res lib/ocaml/Error.resi +lib/ocaml/Exn.cmi +lib/ocaml/Exn.cmj +lib/ocaml/Exn.cmt +lib/ocaml/Exn.cmti +lib/ocaml/Exn.res +lib/ocaml/Exn.resi lib/ocaml/Float.cmi lib/ocaml/Float.cmj lib/ocaml/Float.cmt @@ -823,12 +829,6 @@ lib/ocaml/Js_dict.cmt lib/ocaml/Js_dict.cmti lib/ocaml/Js_dict.res lib/ocaml/Js_dict.resi -lib/ocaml/Js_exn.cmi -lib/ocaml/Js_exn.cmj -lib/ocaml/Js_exn.cmt -lib/ocaml/Js_exn.cmti -lib/ocaml/Js_exn.res -lib/ocaml/Js_exn.resi lib/ocaml/Js_extern.cmi lib/ocaml/Js_extern.cmj lib/ocaml/Js_extern.cmt diff --git a/runtime/Js_exn.res b/runtime/Exn.res similarity index 100% rename from runtime/Js_exn.res rename to runtime/Exn.res diff --git a/runtime/Js_exn.resi b/runtime/Exn.resi similarity index 100% rename from runtime/Js_exn.resi rename to runtime/Exn.resi diff --git a/runtime/Js.res b/runtime/Js.res index 72c535cdb6..fbca7efc08 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -86,7 +86,7 @@ module Nullable = Js_null_undefined module Null_undefined = Js_null_undefined /** Provide utilities for dealing with Js exceptions */ -module Exn = Js_exn +module Exn = Exn /** Provide bindings to JS array*/ module Array = Js_array diff --git a/runtime/Js_null.res b/runtime/Js_null.res index 33f73888f2..1943fc60f4 100644 --- a/runtime/Js_null.res +++ b/runtime/Js_null.res @@ -36,7 +36,7 @@ external getUnsafe: t<'a> => 'a = "%identity" let getExn = f => switch toOption(f) { - | None => Js_exn.raiseError("Js.Null.getExn") + | None => Exn.raiseError("Js.Null.getExn") | Some(x) => x } diff --git a/runtime/Js_option.res b/runtime/Js_option.res index 8cb8074247..fb48406df4 100644 --- a/runtime/Js_option.res +++ b/runtime/Js_option.res @@ -86,7 +86,7 @@ If given `None`, it throws a `getExn` exception. */ let getExn = x => switch x { - | None => Js_exn.raiseError("getExn") + | None => Exn.raiseError("getExn") | Some(x) => x } diff --git a/runtime/Js_undefined.res b/runtime/Js_undefined.res index 00924699ee..699004cea6 100644 --- a/runtime/Js_undefined.res +++ b/runtime/Js_undefined.res @@ -37,7 +37,7 @@ external getUnsafe: t<'a> => 'a = "%identity" let getExn = f => switch toOption(f) { - | None => Js_exn.raiseError("Js.Undefined.getExn") + | None => Exn.raiseError("Js.Undefined.getExn") | Some(x) => x } diff --git a/tests/tests/src/custom_error_test.js b/tests/tests/src/custom_error_test.js index 37400226b7..12e8246a47 100644 --- a/tests/tests/src/custom_error_test.js +++ b/tests/tests/src/custom_error_test.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Js_exn = require("rescript/lib/js/Js_exn.js"); +let Exn = require("rescript/lib/js/Exn.js"); let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); function test_js_error() { @@ -10,7 +10,7 @@ function test_js_error() { e = JSON.parse(" {\"x\" : }"); } catch (raw_err) { let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Js_exn.$$Error) { + if (err.RE_EXN_ID === Exn.$$Error) { console.log(err._1.stack); return; } @@ -24,7 +24,7 @@ function test_js_error2() { return JSON.parse(" {\"x\" : }"); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Js_exn.$$Error) { + if (e.RE_EXN_ID === Exn.$$Error) { console.log(e._1.stack); throw e; } @@ -38,7 +38,7 @@ function example1() { v = JSON.parse(" {\"x\" }"); } catch (raw_err) { let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Js_exn.$$Error) { + if (err.RE_EXN_ID === Exn.$$Error) { console.log(err._1.stack); return; } @@ -52,7 +52,7 @@ function example2() { return JSON.parse(" {\"x\"}"); } catch (raw_exn) { let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Js_exn.$$Error) { + if (exn.RE_EXN_ID === Exn.$$Error) { return; } throw exn; diff --git a/tests/tests/src/exception_raise_test.js b/tests/tests/src/exception_raise_test.js index 622bf8e091..4b7f7b2fba 100644 --- a/tests/tests/src/exception_raise_test.js +++ b/tests/tests/src/exception_raise_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Js_exn = require("rescript/lib/js/Js_exn.js"); +let Exn = require("rescript/lib/js/Exn.js"); let Belt_List = require("rescript/lib/js/Belt_List.js"); let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); @@ -90,7 +90,7 @@ try { a0 = (function (){throw 2} ()); } catch (raw_x$3) { let x$3 = Primitive_exceptions.internalToException(raw_x$3); - if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === Js_exn.$$Error) { + if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === Exn.$$Error) { a0 = x$3._1; } else { throw { @@ -145,7 +145,7 @@ let suites = { hd: [ "File \"exception_raise_test.res\", line 123, characters 6-13", () => { - if (a1.RE_EXN_ID === Js_exn.$$Error) { + if (a1.RE_EXN_ID === Exn.$$Error) { return { TAG: "Eq", _0: a1._1, @@ -180,7 +180,7 @@ try { ((()=>{throw 2})()); } catch (raw_e$2) { let e = Primitive_exceptions.internalToException(raw_e$2); - eq("File \"exception_raise_test.res\", line 137, characters 10-17", Js_exn.asJsExn(e) !== undefined, true); + eq("File \"exception_raise_test.res\", line 137, characters 10-17", Exn.asJsExn(e) !== undefined, true); } try { @@ -190,7 +190,7 @@ try { }; } catch (raw_e$3) { let e$1 = Primitive_exceptions.internalToException(raw_e$3); - eq("File \"exception_raise_test.res\", line 141, characters 10-17", Js_exn.asJsExn(e$1) !== undefined, false); + eq("File \"exception_raise_test.res\", line 141, characters 10-17", Exn.asJsExn(e$1) !== undefined, false); } function fff0(x, g) { diff --git a/tests/tests/src/exception_value_test.js b/tests/tests/src/exception_value_test.js index d84820c514..dccedce368 100644 --- a/tests/tests/src/exception_value_test.js +++ b/tests/tests/src/exception_value_test.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Js_exn = require("rescript/lib/js/Js_exn.js"); +let Exn = require("rescript/lib/js/Exn.js"); let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); function f() { @@ -61,7 +61,7 @@ function test_js_error2() { return JSON.parse(" {\"x\" : }"); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Js_exn.$$Error) { + if (e.RE_EXN_ID === Exn.$$Error) { console.log(e._1.stack); throw e; } diff --git a/tests/tests/src/js_exception_catch_test.js b/tests/tests/src/js_exception_catch_test.js index 54f13628b4..60a773a8a0 100644 --- a/tests/tests/src/js_exception_catch_test.js +++ b/tests/tests/src/js_exception_catch_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Js_exn = require("rescript/lib/js/Js_exn.js"); +let Exn = require("rescript/lib/js/Exn.js"); let Pervasives = require("rescript/lib/js/Pervasives.js"); let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); @@ -57,7 +57,7 @@ try { exit = 1; } catch (raw_x) { let x = Primitive_exceptions.internalToException(raw_x); - if (x.RE_EXN_ID === Js_exn.$$Error) { + if (x.RE_EXN_ID === Exn.$$Error) { add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", () => ({ TAG: "Ok", _0: true @@ -108,7 +108,7 @@ function test(f) { } else { return "C"; } - } else if (e.RE_EXN_ID === Js_exn.$$Error) { + } else if (e.RE_EXN_ID === Exn.$$Error) { return "Js_error"; } else { return "Any"; @@ -170,7 +170,7 @@ eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => }; }), "C_any"); -eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => Js_exn.raiseError("x")), "Js_error"); +eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => Exn.raiseError("x")), "Js_error"); eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => Pervasives.failwith("x")), "Any");