diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index 15936ed867..e247d675ea 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -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 { DirectiveMetadataReader, Parser, Lexer, + ExceptionHandler, bind(XHR).toValue(new XHRImpl()), ]; } diff --git a/modules/angular2/src/core/exception_handler.js b/modules/angular2/src/core/exception_handler.js new file mode 100644 index 0000000000..43c1cd6fc4 --- /dev/null +++ b/modules/angular2/src/core/exception_handler.js @@ -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}`); + } +}