Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { ErrorHandler, Inject } from '@angular/core';
import { AlertController } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
export class MyErrorHandler implements ErrorHandler {
constructor(
private alerts: AlertController,
public splashScreen: SplashScreen,
) {}
public handleError(error) {
this.presentAlert();
}
public presentAlert() {
const alert = this.alerts.create({
title: 'An Error Has Occurred',
subTitle: 'Unfortunately, the app needs to be restarted',
enableBackdropDismiss: false,
buttons: [
{
text: 'Restart',
handler: () => {
this.splashScreen.show();
window.location.reload();
}
}
]
});
alert.present();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment