From 3554ea223810022bad6f6354515dd9579f57c386 Mon Sep 17 00:00:00 2001 From: Oliver Medhurst Date: Thu, 5 Dec 2024 01:23:00 +0000 Subject: [PATCH] wrap: simplify lut exception creation even more --- compiler/wrap.js | 14 ++++++-------- package.json | 2 +- runner/index.js | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/wrap.js b/compiler/wrap.js index 979de15d..55c6a249 100644 --- a/compiler/wrap.js +++ b/compiler/wrap.js @@ -514,17 +514,15 @@ export default (source, module = undefined, customImports = {}, print = str => p const exceptionMode = Prefs.exceptionMode ?? 'stack'; if (exceptionMode === 'lut') { const exceptId = e.getArg(exceptTag, 0); - const exception = exceptions[exceptId]; - - const constructorName = exception.constructor; + const { constructor, message } = exceptions[exceptId]; // no constructor, just throw message - if (!constructorName) throw exception.message; + if (!constructor) throw message; - const err = new Error(obj.message); - err.name = constructorName; - err.stack = `${constructorName}: ${exception.message}`; - throw new constructor(exception.message); + const err = new Error(message); + err.name = constructor; + err.stack = `${constructor}: ${message}`; + return err; } const value = e.getArg(exceptTag, 0); diff --git a/package.json b/package.json index 531549b6..07c45afe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "porffor", "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js", - "version": "0.50.15", + "version": "0.50.16", "author": "CanadaHonk", "license": "MIT", "scripts": {}, diff --git a/runner/index.js b/runner/index.js index f60d5a0a..23f52dc5 100644 --- a/runner/index.js +++ b/runner/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node import fs from 'node:fs'; -globalThis.version = '0.50.15'; +globalThis.version = '0.50.16'; // deno compat if (typeof process === 'undefined' && typeof Deno !== 'undefined') {