mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
28 lines
703 B
TypeScript
28 lines
703 B
TypeScript
// Errors held in checked-dynamic slots (a caught value, an 'unknown'
|
|
// binding, a record field) print through console.log/console.error with
|
|
// Node's error rendering. Stack traces are disabled so both runtimes print
|
|
// the stackless bracket form.
|
|
Error.stackTraceLimit = 0;
|
|
|
|
try {
|
|
JSON.parse("");
|
|
} catch (err) {
|
|
console.error("failed:", err);
|
|
console.log(err);
|
|
console.log("message:", (err as Error).message);
|
|
}
|
|
|
|
const stored: unknown = new RangeError("out of range");
|
|
console.log(stored);
|
|
console.log([stored]);
|
|
|
|
function fail(code: number): never {
|
|
throw new TypeError(`bad input ${code}`);
|
|
}
|
|
try {
|
|
fail(7);
|
|
} catch (e) {
|
|
console.log({ caught: e });
|
|
console.error("handled", e);
|
|
}
|