// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs";
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs";

function test_js_error() {
  let e;
  try {
    e = JSON.parse(` {"x" : }`);
  } catch (raw_err) {
    let err = Primitive_exceptions.internalToException(raw_err);
    if (err.RE_EXN_ID === Stdlib_Exn.$$Error) {
      console.log(err._1.stack);
      return;
    }
    throw err;
  }
  return e;
}

function test_js_error2() {
  try {
    return JSON.parse(` {"x" : }`);
  } catch (raw_e) {
    let e = Primitive_exceptions.internalToException(raw_e);
    if (e.RE_EXN_ID === Stdlib_Exn.$$Error) {
      console.log(e._1.stack);
      throw e;
    }
    throw e;
  }
}

function example1() {
  let v;
  try {
    v = JSON.parse(` {"x"  }`);
  } catch (raw_err) {
    let err = Primitive_exceptions.internalToException(raw_err);
    if (err.RE_EXN_ID === Stdlib_Exn.$$Error) {
      console.log(err._1.stack);
      return;
    }
    throw err;
  }
  return v;
}

function example2() {
  try {
    return JSON.parse(` {"x"}`);
  } catch (raw_exn) {
    let exn = Primitive_exceptions.internalToException(raw_exn);
    if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) {
      return;
    }
    throw exn;
  }
}

export {
  test_js_error,
  test_js_error2,
  example1,
  example2,
}
/* No side effect */
