From 2cd4a85ed4c57a705e3aeb88052be616e0461187 Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Sat, 19 Nov 2016 16:33:29 +0100
Subject: better error reporting

---
 src/pages/confirm-create-reserve.tsx | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

(limited to 'src/pages/confirm-create-reserve.tsx')

diff --git a/src/pages/confirm-create-reserve.tsx b/src/pages/confirm-create-reserve.tsx
index 963bd0697..81a90650c 100644
--- a/src/pages/confirm-create-reserve.tsx
+++ b/src/pages/confirm-create-reserve.tsx
@@ -374,14 +374,24 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
 }
 
 export async function main() {
-  const url = URI(document.location.href);
-  const query: any = URI.parseQuery(url.query());
-  const amount = AmountJson.checked(JSON.parse(query.amount));
-  const callback_url = query.callback_url;
-  const bank_url = query.bank_url;
-  const wt_types = JSON.parse(query.wt_types);
-
   try {
+    const url = URI(document.location.href);
+    const query: any = URI.parseQuery(url.query());
+    let amount;
+    try {
+      amount = AmountJson.checked(JSON.parse(query.amount));
+    } catch (e) {
+      throw Error(`Can't parse amount: ${e.message}`);
+    }
+    const callback_url = query.callback_url;
+    const bank_url = query.bank_url;
+    let wt_types;
+    try {
+      wt_types = JSON.parse(query.wt_types);
+    } catch (e) {
+      throw Error(`Can't parse wire_types: ${e.message}`);
+    }
+
     const suggestedExchangeUrl = await getSuggestedExchange(amount.currency);
     let args = {
       wt_types,
-- 
cgit v1.2.3

