diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-01-29 18:59:45 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-01-29 18:59:45 +0100 |
commit | 9fe6dc596573f38b13f0b15c946b8bc16013fdd9 (patch) | |
tree | 6fe2ba7264d488d3189b0ab560d2685b14e4fe12 /src/webex/pages | |
parent | 83674bd7a9d4524753f6d438ea88b76a52d43a9b (diff) | |
download | wallet-core-9fe6dc596573f38b13f0b15c946b8bc16013fdd9.tar.xz |
better error handling
Diffstat (limited to 'src/webex/pages')
-rw-r--r-- | src/webex/pages/confirm-contract.tsx | 1 | ||||
-rw-r--r-- | src/webex/pages/confirm-create-reserve.tsx | 22 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index 6089d0f8a..21f05d5d6 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -256,7 +256,6 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt } this.setState({ confirmPayError: e.detail }); return; - } finally { } console.log("payResult", payResult); document.location.href = payResult.nextUrl; diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx index 903975c6e..bd21280c3 100644 --- a/src/webex/pages/confirm-create-reserve.tsx +++ b/src/webex/pages/confirm-create-reserve.tsx @@ -42,6 +42,7 @@ import { getCurrency, getExchangeInfo, getReserveCreationInfo, + WalletApiError, } from "../wxApi"; import { @@ -117,7 +118,8 @@ class ManualSelection extends ImplicitStateComponent<ManualSelectionProps> { <input className="url" type="text" spellCheck={false} value={this.url()} key="exchange-url-input" - onInput={(e) => this.onUrlChanged((e.target as HTMLInputElement).value)} /> + onInput={(e) => this.onUrlChanged((e.target as HTMLInputElement).value)} + onChange={(e) => this.onUrlChanged((e.target as HTMLInputElement).value)} /> </div> <div className="pure-u-1"> <button className="pure-button button-success" @@ -125,6 +127,7 @@ class ManualSelection extends ImplicitStateComponent<ManualSelectionProps> { onClick={() => this.props.onSelect(this.url())}> {i18n.str`Select`} </button> + <span> </span> {this.errorMessage()} </div> </div> @@ -149,15 +152,12 @@ class ManualSelection extends ImplicitStateComponent<ManualSelectionProps> { console.log("getExchangeInfo returned"); this.isOkay(true); } catch (e) { - console.log("got error", e); - if (e.hasOwnProperty("httpStatus")) { - this.errorMessage(`Error: request failed with status ${e.httpStatus}`); - } else if (e.hasOwnProperty("errorResponse")) { - const resp = e.errorResponse; - this.errorMessage(`Error: ${resp.error} (${resp.hint})`); - } else { - this.errorMessage("invalid exchange URL"); + if (!(e instanceof WalletApiError)) { + // maybe it's something more serious, don't handle here! + throw e; } + console.log(`got error "${e.message} "with detail`, e.detail); + this.errorMessage(i18n.str`Invalid exchange URL (${e.message})`); } } @@ -345,7 +345,7 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> { <div> <h2>Known Exchanges</h2> {exchanges.map((e) => ( - <button className="pure-button button-success" onClick={() => this.select(e.baseUrl)}> + <button key={e.baseUrl} className="pure-button button-success" onClick={() => this.select(e.baseUrl)}> Select <strong>{e.baseUrl}</strong> </button> ))} @@ -503,7 +503,7 @@ async function main() { // TODO: provide more context information, maybe factor it out into a // TODO:generic error reporting function or component. document.body.innerText = i18n.str`Fatal error: "${e.message}".`; - console.error(`got error "${e.message}"`, e); + console.error("got error", e); } } |