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 {ProtoView} from './compiler/view';
|
||||||
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
||||||
import {Parser, Lexer, ChangeDetection, dynamicChangeDetection, jitChangeDetection} from 'angular2/change_detection';
|
import {Parser, Lexer, ChangeDetection, dynamicChangeDetection, jitChangeDetection} from 'angular2/change_detection';
|
||||||
|
import {ExceptionHandler} from './exception_handler';
|
||||||
import {TemplateLoader} from './compiler/template_loader';
|
import {TemplateLoader} from './compiler/template_loader';
|
||||||
import {TemplateResolver} from './compiler/template_resolver';
|
import {TemplateResolver} from './compiler/template_resolver';
|
||||||
import {DirectiveMetadataReader} from './compiler/directive_metadata_reader';
|
import {DirectiveMetadataReader} from './compiler/directive_metadata_reader';
|
||||||
|
@ -23,7 +24,7 @@ var _rootInjector: Injector;
|
||||||
|
|
||||||
// Contains everything that is safe to share between applications.
|
// Contains everything that is safe to share between applications.
|
||||||
var _rootBindings = [
|
var _rootBindings = [
|
||||||
bind(Reflector).toValue(reflector),
|
bind(Reflector).toValue(reflector)
|
||||||
];
|
];
|
||||||
|
|
||||||
export var appViewToken = new OpaqueToken('AppView');
|
export var appViewToken = new OpaqueToken('AppView');
|
||||||
|
@ -86,6 +87,7 @@ function _injectorBindings(appComponentType): List<Binding> {
|
||||||
DirectiveMetadataReader,
|
DirectiveMetadataReader,
|
||||||
Parser,
|
Parser,
|
||||||
Lexer,
|
Lexer,
|
||||||
|
ExceptionHandler,
|
||||||
bind(XHR).toValue(new XHRImpl()),
|
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