feat: introduce ExceptionHandler service
This commit is contained in:
parent
53d5f36557
commit
a1f4060126
|
@ -5,6 +5,7 @@ import {Compiler, CompilerCache} from './compiler/compiler';
|
|||
import {ProtoView} from './compiler/view';
|
||||
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
||||
import {Parser, Lexer, ChangeDetection, dynamicChangeDetection, jitChangeDetection} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from './exception_handler';
|
||||
import {TemplateLoader} from './compiler/template_loader';
|
||||
import {TemplateResolver} from './compiler/template_resolver';
|
||||
import {DirectiveMetadataReader} from './compiler/directive_metadata_reader';
|
||||
|
@ -23,7 +24,7 @@ var _rootInjector: Injector;
|
|||
|
||||
// Contains everything that is safe to share between applications.
|
||||
var _rootBindings = [
|
||||
bind(Reflector).toValue(reflector),
|
||||
bind(Reflector).toValue(reflector)
|
||||
];
|
||||
|
||||
export var appViewToken = new OpaqueToken('AppView');
|
||||
|
@ -86,6 +87,7 @@ function _injectorBindings(appComponentType): List<Binding> {
|
|||
DirectiveMetadataReader,
|
||||
Parser,
|
||||
Lexer,
|
||||
ExceptionHandler,
|
||||
bind(XHR).toValue(new XHRImpl()),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import {isPresent, print} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
|
||||
|
||||
export class ExceptionHandler {
|
||||
call(error, stackTrace = null, reason = null) {
|
||||
var longStackTrace = isListLikeIterable(stackTrace) ? ListWrapper.join(stackTrace, "\n\n") : stackTrace;
|
||||
var reasonStr = isPresent(reason) ? `\n${reason}` : '';
|
||||
print(`${error}${reasonStr}\nSTACKTRACE:\n${longStackTrace}`);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue