From 2a5c0c1c7a90030722a2def17a73a1738240766c Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 21 Oct 2015 10:47:07 +1030 Subject: [PATCH] Improve request error debug output --- js/lib/App.js | 4 ++-- js/lib/components/RequestErrorModal.js | 11 ++++++++++- js/lib/utils/RequestError.js | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/lib/App.js b/js/lib/App.js index 618271348..f1d05594e 100644 --- a/js/lib/App.js +++ b/js/lib/App.js @@ -206,7 +206,7 @@ export default class App { try { return JSON.parse(responseText); } catch (e) { - throw new RequestError(500, responseText); + throw new RequestError(500, responseText, options, xhr); } }); @@ -230,7 +230,7 @@ export default class App { const status = xhr.status; if (status < 200 || status > 299) { - throw new RequestError(status, responseText, xhr); + throw new RequestError(status, responseText, options, xhr); } return responseText; diff --git a/js/lib/components/RequestErrorModal.js b/js/lib/components/RequestErrorModal.js index 5ef8468c0..90792d329 100644 --- a/js/lib/components/RequestErrorModal.js +++ b/js/lib/components/RequestErrorModal.js @@ -5,6 +5,12 @@ export default class RequestErrorModal extends Modal { return 'RequestErrorModal Modal--large'; } + title() { + return this.props.error.xhr + ? this.props.error.xhr.status+' '+this.props.error.xhr.statusText + : ''; + } + content() { let responseText; @@ -15,7 +21,10 @@ export default class RequestErrorModal extends Modal { } return
-
{responseText}
+
+        {this.props.error.options.method} {this.props.error.options.url}

+ {responseText} +
; } } diff --git a/js/lib/utils/RequestError.js b/js/lib/utils/RequestError.js index d3f9b30d4..3346e673f 100644 --- a/js/lib/utils/RequestError.js +++ b/js/lib/utils/RequestError.js @@ -1,7 +1,8 @@ export default class RequestError { - constructor(status, responseText, xhr) { + constructor(status, responseText, options, xhr) { this.status = status; this.responseText = responseText; + this.options = options; this.xhr = xhr; try {