fix(exception_handler): fix error messages of wrapped exceptions
Closes #4117
This commit is contained in:
45
modules/angular2/src/core/facade/exceptions.ts
Normal file
45
modules/angular2/src/core/facade/exceptions.ts
Normal file
@ -0,0 +1,45 @@
|
||||
/// <reference path="../../../manual_typings/globals.d.ts" />
|
||||
|
||||
import {ExceptionHandler} from './exception_handler';
|
||||
|
||||
export {ExceptionHandler} from './exception_handler';
|
||||
|
||||
export class BaseException extends Error {
|
||||
public stack: any;
|
||||
constructor(public message?: string) {
|
||||
super(message);
|
||||
this.stack = (<any>new Error(message)).stack;
|
||||
}
|
||||
|
||||
toString(): string { return this.message; }
|
||||
}
|
||||
|
||||
export class WrappedException extends Error {
|
||||
private _wrapperStack: any;
|
||||
|
||||
constructor(private _wrapperMessage: string, private _originalException, private _originalStack?,
|
||||
private _context?) {
|
||||
super(_wrapperMessage);
|
||||
this._wrapperStack = (<any>new Error(_wrapperMessage)).stack;
|
||||
}
|
||||
|
||||
get wrapperMessage(): string { return this._wrapperMessage; }
|
||||
|
||||
get wrapperStack(): any { return this._wrapperStack; }
|
||||
|
||||
|
||||
get originalException(): any { return this._originalException; }
|
||||
|
||||
get originalStack(): any { return this._originalStack; }
|
||||
|
||||
|
||||
get context(): any { return this._context; }
|
||||
|
||||
get message(): string { return ExceptionHandler.exceptionToString(this); }
|
||||
|
||||
toString(): string { return this.message; }
|
||||
}
|
||||
|
||||
export function makeTypeError(message?: string): Error {
|
||||
return new TypeError(message);
|
||||
}
|
Reference in New Issue
Block a user