diff --git a/src/value.ts b/src/value.ts index af1930e..be429e3 100644 --- a/src/value.ts +++ b/src/value.ts @@ -61,7 +61,7 @@ export function toValue(v: any): Value /* throws */ { case 'string': return { type: 'string', value: v } case 'function': - throw "can't toValue() a js function yet" + throw new Error("can't toValue() a js function yet") case 'object': const dict: Dict = new Map() @@ -69,7 +69,7 @@ export function toValue(v: any): Value /* throws */ { return { type: 'dict', value: dict } default: - throw `can't toValue this: ${v}` + throw new Error(`can't toValue this: ${v}`) } } diff --git a/src/vm.ts b/src/vm.ts index 30ee039..7b8cd24 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -37,7 +37,8 @@ export class VM { const value = this.scope.get(name) if (!value) throw new Error(`Can't find ${name}`) - if (value.type !== 'function' && value.type !== 'native') throw new Error(`Can't call ${name}`) + if (value.type !== 'function' && value.type !== 'native') + throw new Error(`Can't call ${name}`) if (value.type === 'native') { return await this.callNative(value.fn, args) @@ -725,7 +726,7 @@ export class VM { break default: - throw `Unknown op: ${instruction.op}` + throw new Error(`Unknown op: ${instruction.op}`) } }