From dbf2e24369aaf6fbc00030f2615c0852e41a9db6 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 13 Nov 2021 07:57:08 +0000 Subject: [PATCH] Make webhook handler more robust to API failures --- src/web.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/web.rs b/src/web.rs index d2283bb..a55dcb6 100644 --- a/src/web.rs +++ b/src/web.rs @@ -179,10 +179,19 @@ async fn monzo_hook(hook: MonzoHook, state: State) -> anyhow::Result { + let new_bal = resp.balance; + let now_quid = new_bal / 100; + let now_pennies = new_bal % 100; + buf.push_str(&format!(" now £{}.{:02}", now_quid, now_pennies)); + } + Err(err) => { + buf.push_str(". Error when getting now."); + eprintln!("when querying balance after webhook: {:?}", err); + } + } + } let content = MessageEventContent::text_plain(&buf);