Skip to content

Commit

Permalink
feat(exception_handler): changed ExceptionHandler to use console.erro…
Browse files Browse the repository at this point in the history
…r instead of console.log

Closes #3812
  • Loading branch information
vsavkin committed Aug 28, 2015
1 parent a34d4c6 commit 3bb27de
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions modules/angular2/src/core/dom/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {

logGroup(error) {
window.console.group(error);
this.logError(error);
}

logGroupEnd() {
Expand Down
9 changes: 8 additions & 1 deletion modules/angular2/src/core/dom/browser_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}

// TODO(tbosch): move this into a separate environment class once we have it
logError(error) { window.console.error(error); }
logError(error) {
if (window.console.error) {
window.console.error(error);
} else {
window.console.log(error);
}
}

log(error) { window.console.log(error); }

logGroup(error) {
if (window.console.group) {
window.console.group(error);
this.logError(error);
} else {
window.console.log(error);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/dom/parse5_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Parse5DomAdapter extends DomAdapter {

log(error) { console.log(error); }

logGroup(error) { console.log(error); }
logGroup(error) { console.error(error); }

logGroupEnd() {}

Expand Down
17 changes: 9 additions & 8 deletions modules/angular2/src/core/exception_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ListWrapper, isListLikeIterable} from 'angular2/src/core/facade/collecti
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}
Expand Down Expand Up @@ -49,26 +50,26 @@ export class ExceptionHandler {
this.logger.logGroup(`EXCEPTION: ${exception}`);

if (isPresent(stackTrace) && isBlank(originalStack)) {
this.logger.log("STACKTRACE:");
this.logger.log(this._longStackTrace(stackTrace));
this.logger.logError("STACKTRACE:");
this.logger.logError(this._longStackTrace(stackTrace));
}

if (isPresent(reason)) {
this.logger.log(`REASON: ${reason}`);
this.logger.logError(`REASON: ${reason}`);
}

if (isPresent(originalException)) {
this.logger.log(`ORIGINAL EXCEPTION: ${originalException}`);
this.logger.logError(`ORIGINAL EXCEPTION: ${originalException}`);
}

if (isPresent(originalStack)) {
this.logger.log("ORIGINAL STACKTRACE:");
this.logger.log(this._longStackTrace(originalStack));
this.logger.logError("ORIGINAL STACKTRACE:");
this.logger.logError(this._longStackTrace(originalStack));
}

if (isPresent(context)) {
this.logger.log("ERROR CONTEXT:");
this.logger.log(context);
this.logger.logError("ERROR CONTEXT:");
this.logger.logError(context);
}

this.logger.logGroupEnd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var _rootBindings = [bind(Reflector).toValue(reflector)];

class PrintLogger {
log = print;
logError = print;
logGroup = print;
logGroupEnd() {}
}
Expand Down
1 change: 1 addition & 0 deletions modules/angular2/test/core/application_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class HelloRootDirectiveIsNotCmp {
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}
Expand Down
1 change: 1 addition & 0 deletions modules/angular2/test/router/route_config_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}
Expand Down

0 comments on commit 3bb27de

Please sign in to comment.