From 2ac3ac8cd3f21bedcd0ea849a60029384271d94f Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 23 Mar 2018 17:15:09 -0400 Subject: [PATCH] added error messaging to toast --- app/src/pages/broadcast-tx/broadcast-tx.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/pages/broadcast-tx/broadcast-tx.ts b/app/src/pages/broadcast-tx/broadcast-tx.ts index 14f0811..044e4f4 100644 --- a/app/src/pages/broadcast-tx/broadcast-tx.ts +++ b/app/src/pages/broadcast-tx/broadcast-tx.ts @@ -38,16 +38,18 @@ export class BroadcastTxPage { this.http.post(this.api.apiPrefix + 'tx/send', postData) .subscribe( response => { - this.presentToast(response); + this.presentToast(true, response); }, - err => console.log('err', err) + err => { + this.presentToast(false, err); + } ); } - private presentToast(response: any): void { - let body: any = JSON.parse(response._body); + private presentToast(success: boolean, response: any): void { + let message: string = (success) ? 'Transaction successfully broadcast. Trasaction id: ' + JSON.parse(response._body).txid : 'An error occurred: ' + response._body; let toast: any = this.toastCtrl.create({ - message: 'Transaction successfully broadcast. Trasaction id: ' + body.txid, + message: message, position: 'middle', showCloseButton: true, dismissOnPageChange: true