feat: introduce ExceptionHandler service

This commit is contained in:
Pawel Kozlowski 2015-02-16 14:35:27 +01:00
parent 53d5f36557
commit a1f4060126
2 changed files with 13 additions and 1 deletions

View File

@ -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()),
]; ];
} }

View File

@ -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}`);
}
}