Last active
February 26, 2018 10:31
-
-
Save MichaelMarner/f4dcdb094e034079185cdc8932f1c784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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