Skip to content

Commit 3bb27de

Browse files
committed
feat(exception_handler): changed ExceptionHandler to use console.error instead of console.log
Closes angular#3812
1 parent a34d4c6 commit 3bb27de

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

modules/angular2/src/core/dom/browser_adapter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
157157

158158
logGroup(error) {
159159
window.console.group(error);
160+
this.logError(error);
160161
}
161162

162163
logGroupEnd() {

modules/angular2/src/core/dom/browser_adapter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,20 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
6464
}
6565

6666
// TODO(tbosch): move this into a separate environment class once we have it
67-
logError(error) { window.console.error(error); }
67+
logError(error) {
68+
if (window.console.error) {
69+
window.console.error(error);
70+
} else {
71+
window.console.log(error);
72+
}
73+
}
6874

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

7177
logGroup(error) {
7278
if (window.console.group) {
7379
window.console.group(error);
80+
this.logError(error);
7481
} else {
7582
window.console.log(error);
7683
}

modules/angular2/src/core/dom/parse5_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class Parse5DomAdapter extends DomAdapter {
5252

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

55-
logGroup(error) { console.log(error); }
55+
logGroup(error) { console.error(error); }
5656

5757
logGroupEnd() {}
5858

modules/angular2/src/core/exception_handler.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {ListWrapper, isListLikeIterable} from 'angular2/src/core/facade/collecti
55
class _ArrayLogger {
66
res: any[] = [];
77
log(s: any): void { this.res.push(s); }
8+
logError(s: any): void { this.res.push(s); }
89
logGroup(s: any): void { this.res.push(s); }
910
logGroupEnd(){};
1011
}
@@ -49,26 +50,26 @@ export class ExceptionHandler {
4950
this.logger.logGroup(`EXCEPTION: ${exception}`);
5051

5152
if (isPresent(stackTrace) && isBlank(originalStack)) {
52-
this.logger.log("STACKTRACE:");
53-
this.logger.log(this._longStackTrace(stackTrace));
53+
this.logger.logError("STACKTRACE:");
54+
this.logger.logError(this._longStackTrace(stackTrace));
5455
}
5556

5657
if (isPresent(reason)) {
57-
this.logger.log(`REASON: ${reason}`);
58+
this.logger.logError(`REASON: ${reason}`);
5859
}
5960

6061
if (isPresent(originalException)) {
61-
this.logger.log(`ORIGINAL EXCEPTION: ${originalException}`);
62+
this.logger.logError(`ORIGINAL EXCEPTION: ${originalException}`);
6263
}
6364

6465
if (isPresent(originalStack)) {
65-
this.logger.log("ORIGINAL STACKTRACE:");
66-
this.logger.log(this._longStackTrace(originalStack));
66+
this.logger.logError("ORIGINAL STACKTRACE:");
67+
this.logger.logError(this._longStackTrace(originalStack));
6768
}
6869

6970
if (isPresent(context)) {
70-
this.logger.log("ERROR CONTEXT:");
71-
this.logger.log(context);
71+
this.logger.logError("ERROR CONTEXT:");
72+
this.logger.logError(context);
7273
}
7374

7475
this.logger.logGroupEnd();

modules/angular2/src/web_workers/worker/application_common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ var _rootBindings = [bind(Reflector).toValue(reflector)];
7171

7272
class PrintLogger {
7373
log = print;
74+
logError = print;
7475
logGroup = print;
7576
logGroupEnd() {}
7677
}

modules/angular2/test/core/application_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class HelloRootDirectiveIsNotCmp {
6969
class _ArrayLogger {
7070
res: any[] = [];
7171
log(s: any): void { this.res.push(s); }
72+
logError(s: any): void { this.res.push(s); }
7273
logGroup(s: any): void { this.res.push(s); }
7374
logGroupEnd(){};
7475
}

modules/angular2/test/router/route_config_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
3333
class _ArrayLogger {
3434
res: any[] = [];
3535
log(s: any): void { this.res.push(s); }
36+
logError(s: any): void { this.res.push(s); }
3637
logGroup(s: any): void { this.res.push(s); }
3738
logGroupEnd(){};
3839
}

0 commit comments

Comments
 (0)