Skip to content

Commit

Permalink
improved error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoemp committed Feb 12, 2020
1 parent 2682569 commit d3c5c88
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
const oldError = console.error;
(() => {
// tslint:disable-next-line:only-arrow-functions
console.error = function (error) {
console.error = function (error, context) {
let debug = '';
let stack = '';

if (typeof error === 'string') {
debug = error;

if (error === 'ERROR' && !isNullOrUndefined(context) && context.hasOwnProperty('stack') && context.hasOwnProperty('message')) {
debug = context.message;
stack = context.stack;
}
} else {
if (error instanceof Error) {
debug = error.message;
Expand All @@ -85,7 +90,7 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
}

if (debug !== '') {
serv.addEntry(ConsoleType.ERROR, `${debug}: ${stack}`);
serv.addEntry(ConsoleType.ERROR, `${debug}${(stack !== '') ? ' ' + stack : ''}`);
}

oldError.apply(console, arguments);
Expand All @@ -105,6 +110,9 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
}

ngOnInit() {
setTimeout(() => {
console.error(`test fehler`);
}, 4000);
this.subscrmanager.add(this.settingsService.dbloaded.subscribe(
() => {
if (!isNullOrUndefined(this.appStorage.asrSelectedService) && !isNullOrUndefined(this.appStorage.asrSelectedLanguage)) {
Expand Down

0 comments on commit d3c5c88

Please sign in to comment.