Skip to content

Instantly share code, notes, and snippets.

@AhsanAyaz
Created January 29, 2018 15:23
Show Gist options
  • Save AhsanAyaz/aca5bc4237e63ef88330ea2b48224c4a to your computer and use it in GitHub Desktop.
Save AhsanAyaz/aca5bc4237e63ef88330ea2b48224c4a to your computer and use it in GitHub Desktop.
import { Pro } from '@ionic/pro';
import { Injectable, ErrorHandler, Injector } from '@angular/core';
import { IonicErrorHandler } from 'ionic-angular';
// initializing the Ionic Pro client
const IonicPro = Pro.init('APP_ID', {
appVersion: "APP_VERSION"
});
@Injectable()
export class AppErrorHandlerProvider implements ErrorHandler {
ionicErrorHandler: IonicErrorHandler;
constructor(injector: Injector) {
try {
this.ionicErrorHandler = injector.get(IonicErrorHandler);
} catch(e) {
// Unable to get the IonicErrorHandler provider, ensure
// IonicErrorHandler has been added to the providers list below
}
}
handleError(err: any): void {
IonicPro.monitoring.handleNewError(err); // Remove this if you want to disable Ionic's auto exception handling in development mode.
this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment