App Crashes - logging the Exception


#1

I have a cordova plugin that I’m trying to incorporate to my app, and when I start the plugin, the app crashes hard. I try to wrap the code I’m calling in some exception handling, but my monitoring/logging code fails to execute. As I understand it, anything not handled will bubble up to the error handler class, and I’ve implemented Ionic Pro Monitoring with a custom error handler in my app.module, which has the following code:

@Injectable()
export class MyErrorHandler 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 {
    Pro.monitoring.handleNewError(err);
    // Remove this if you want to disable Ionic's auto exception handling
    // in development mode.
    this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);
  }
}

As I understand it, anything not caught in the code (which should be happening, but isn’t for some reason) will bubble up here - but this code isn’t called either.

I’ve tested that my monitoring/logging code works with a fake exception, so what am I missing?