fix(exception_handler): log errors via console.error

This is e.g. needed as we use this to test for errors
in our examples.
This commit is contained in:
Tobias Bosch
2015-04-30 11:25:50 -07:00
parent 87dcd5eb6f
commit ead21c91a4
10 changed files with 52 additions and 20 deletions

View File

@ -134,7 +134,7 @@ function _injectorBindings(appComponentType): List<Binding> {
function _createVmZone(givenReporter:Function): VmTurnZone {
var defaultErrorReporter = (exception, stackTrace) => {
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
print(`${exception}\n\n${longStackTrace}`);
DOM.logError(`${exception}\n\n${longStackTrace}`);
throw exception;
};

View File

@ -1,6 +1,7 @@
import {Injectable} from 'angular2/di';
import {isPresent, print} from 'angular2/src/facade/lang';
import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/dom/dom_adapter';
/**
* Provides a hook for centralized exception handling.
@ -36,6 +37,6 @@ 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}`);
DOM.logError(`${error}${reasonStr}\nSTACKTRACE:\n${longStackTrace}`);
}
}