Skip to content

Commit

Permalink
Include request/response info with Abort error
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Heaton committed Sep 14, 2018
1 parent e17365a commit c76d07c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addon/adapters/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ function ajaxError(adapter, payload, requestData, responseData) {
} else if (responseData.textStatus === 'timeout') {
error = new TimeoutError();
} else if (responseData.textStatus === 'abort' || responseData.status === 0) {
error = new AbortError();
error = handleAbort(requestData, responseData);
} else {
try {
error = adapter.handleResponse(
Expand All @@ -1245,6 +1245,15 @@ function ajaxError(adapter, payload, requestData, responseData) {
return error;
}

// Adapter abort error to include any relevent info, e.g. request/response:
function handleAbort(requestData, responseData) {
let { method, url, errorThrown } = requestData;
let { status } = responseData;
let msg = `Request failed: ${method} ${url} ${errorThrown || ''}`;
let errors = [{ title: 'Adapter Error', detail: msg.trim(), status }];
return new AbortError(errors);
}

//From http://stackoverflow.com/questions/280634/endswith-in-javascript
function endsWith(string, suffix) {
if (typeof String.prototype.endsWith !== 'function') {
Expand Down

0 comments on commit c76d07c

Please sign in to comment.