fix(tsc-wrapped): have UserError display the actual error
This commit is contained in:
parent
66b6fc010d
commit
393c1007a8
|
@ -25,12 +25,21 @@ export interface CompilerInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserError extends Error {
|
export class UserError extends Error {
|
||||||
|
private _nativeError: Error;
|
||||||
|
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
super(message);
|
// Errors don't use current this, instead they create a new instance.
|
||||||
this.message = message;
|
// We have to do forward all of our api to the nativeInstance.
|
||||||
this.name = 'UserError';
|
const nativeError = super(message) as any as Error;
|
||||||
this.stack = new Error().stack;
|
this._nativeError = nativeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get message() { return this._nativeError.message; }
|
||||||
|
set message(message) { this._nativeError.message = message; }
|
||||||
|
get name() { return 'UserError'; }
|
||||||
|
get stack() { return (this._nativeError as any).stack; }
|
||||||
|
set stack(value) { (this._nativeError as any).stack = value; }
|
||||||
|
toString() { return this._nativeError.toString(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
|
|
Loading…
Reference in New Issue