throw real errors
This commit is contained in:
parent
bf6607d368
commit
e300946c48
|
|
@ -61,7 +61,7 @@ export function toValue(v: any): Value /* throws */ {
|
||||||
case 'string':
|
case 'string':
|
||||||
return { type: 'string', value: v }
|
return { type: 'string', value: v }
|
||||||
case 'function':
|
case 'function':
|
||||||
throw "can't toValue() a js function yet"
|
throw new Error("can't toValue() a js function yet")
|
||||||
case 'object':
|
case 'object':
|
||||||
const dict: Dict = new Map()
|
const dict: Dict = new Map()
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ export function toValue(v: any): Value /* throws */ {
|
||||||
|
|
||||||
return { type: 'dict', value: dict }
|
return { type: 'dict', value: dict }
|
||||||
default:
|
default:
|
||||||
throw `can't toValue this: ${v}`
|
throw new Error(`can't toValue this: ${v}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ export class VM {
|
||||||
const value = this.scope.get(name)
|
const value = this.scope.get(name)
|
||||||
|
|
||||||
if (!value) throw new Error(`Can't find ${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') {
|
if (value.type === 'native') {
|
||||||
return await this.callNative(value.fn, args)
|
return await this.callNative(value.fn, args)
|
||||||
|
|
@ -725,7 +726,7 @@ export class VM {
|
||||||
break
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw `Unknown op: ${instruction.op}`
|
throw new Error(`Unknown op: ${instruction.op}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user