From 021b8cd46b1fa70a8da2fc867412bb65afd42722 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Mon, 11 May 2020 21:43:15 -0700 Subject: add err messages --- frontend/src/components/NewPaste.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/NewPaste.js b/frontend/src/components/NewPaste.js index 29ae9ca..2ce2ecf 100644 --- a/frontend/src/components/NewPaste.js +++ b/frontend/src/components/NewPaste.js @@ -111,8 +111,17 @@ class NewPaste extends React.Component { }).then((response) => { // on success, redir this.setState({ hash: response.data.hash }) - }).catch((response) => { - this.newErr(response) + }).catch((error) => { + const resp = error.response + + // some weird err + if (resp !== undefined) { + const errTxt = `${resp.statusText}: ${resp.data}` + this.newErr(errTxt) + } else { + // some weird err (e.g. network) + this.newErr(error) + } }); event.preventDefault(); -- cgit v1.2.3