Skip to content

Commit

Permalink
feat: add error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
aldo-maciel committed May 14, 2020
1 parent db5b174 commit 0cee6b7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/shared/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ToastController } from '@ionic/angular';

const toast = new ToastController();

const onToast = async (message: string, color: string = 'success') => {
const instance = await toast.create({
message,
color,
duration: 2000
});
return instance.present();
};

export const onError = async (message: string) => {
return onToast(message, 'danger');
};

export const onSuccess = async (message: string) => {
return onToast(message);
};

0 comments on commit 0cee6b7

Please sign in to comment.