Files
angular/modules/angular2/src/facade/exceptions.ts
vsavkin 79472b77ca refactor(core): move facades out of core
This is part of ongoing work to make core platform-independent.

BREAKING CHANGE

All private exports from 'angular2/src/core/facade/{lang,collection,exception_handler}' should be replaced with 'angular2/src/facade/{lang,collection,exception_handler}'.
2015-11-07 01:36:06 +00:00

48 lines
1.2 KiB
TypeScript

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);
}
export function unimplemented(): any {
throw new BaseException('unimplemented');
}