Skip to content

Commit

Permalink
wrap: simplify lut exception creation even more
Browse files Browse the repository at this point in the history
  • Loading branch information
CanadaHonk committed Dec 5, 2024
1 parent fc5f9f7 commit 3554ea2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions compiler/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down
2 changes: 1 addition & 1 deletion runner/index.js
Original file line number Diff line number Diff line change
@@ -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') {
Expand Down

0 comments on commit 3554ea2

Please sign in to comment.