Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MichaelMarner
Last active February 26, 2018 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelMarner/f4dcdb094e034079185cdc8932f1c784 to your computer and use it in GitHub Desktop.
Save MichaelMarner/f4dcdb094e034079185cdc8932f1c784 to your computer and use it in GitHub Desktop.
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