28 lines
851 B
TypeScript
Raw Normal View History

2020-03-12 16:16:04 +09:00
import { ErrorHandler, Injectable, Injector, NgZone } from '@angular/core';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { error } from 'console';
@Injectable()
export class AppGlobalErrorhandler implements ErrorHandler {
constructor(private injector: Injector, private zone: NgZone) {}
// tslint:disable-next-line: no-shadowed-variable
handleError(error: Error) {
let nativeLogging: any;
try {
const nativeService: NativeService = this.injector.get(
UCAP_NATIVE_SERVICE
);
nativeService.appLogging(error.stack);
nativeLogging = 'SUCCESS';
} catch (e) {
nativeLogging = e;
}
console.groupCollapsed('App Global Error Logging');
console.log('App log', error);
console.log('Native Logging', nativeLogging);
console.groupEnd();
}
}