Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

Plugin_not_installed when extending IonicErrorHandler

$
0
0

@BenedictLewis wrote:

I'm trying to extend the IonicErrorHandler to report errors using Sentry. Part of this includes version tracking, so I'm trying to use the plugin AppVersion to get the current version, and set it on the Sentry plugin.

import { Injectable } from '@angular/core';
import { ErrorHandler } from '@angular/core';
import { IonicErrorHandler } from 'ionic-angular';
import { AppVersion } from '@ionic-native/app-version';
import Raven from 'raven-js';

Raven
  .config('<api key>', {
    dataCallback: data => {

      if (data.culprit) {
        data.culprit = data.culprit.substring(data.culprit.lastIndexOf('/'));
      }

      var stacktrace = data.stacktrace || data.exception && data.exception.values[0].stacktrace;

      if (stacktrace) {
        stacktrace.frames.forEach(function (frame) {
          frame.filename = frame.filename.substring(frame.filename.lastIndexOf('/'));
        });
      }
    }
  }).install();

@Injectable()
export class SentryErrorHandler extends IonicErrorHandler implements ErrorHandler {

  constructor(private appVersion: AppVersion) {
    // Call super constructor
    super();

    // Configure raven
    appVersion.getVersionNumber().then(version => {
      this.configureRaven(version);
    });
  }

  configureRaven(version) {
    Raven.setRelease(version);
  }

  handleError(error) {
    super.handleError(error);

    try {
      Raven.captureException(error.originalError || error);
    }
    catch(e) {
      console.error(e);
    }
  }
}

However, I get the error

Uncaught (in promise): plugin_not_installed

The plugin is installed, as is the node library, and I can use AppVersion inside my other controllers without any problems.

I'm adding it to the providers as follows:

providers: [
  ...
  AppVersion,
  { provide: ErrorHandler, useClass: SentryErrorHandler }
]

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>