Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include request/response info with Abort error #5639

Conversation

pixelhandler
Copy link
Contributor

Currently the AbortError does not have any context about the request/response.

This PR adds the request method, url and error if available...

error.message
"The adapter operation was aborted"
error.errors[0].title
"Adapter Error"
error.errors[0].detail
"Request failed: GET http://localhost:4200/api/v1/reports"
error.errors[0].status
0

The problem is that when you have this error there is no related info captured to identify why the adapter aborted. For example, using a service like bugsnag or raygun, the error may not have any information to help reproduce the problem in your application.

@@ -1228,7 +1228,8 @@ 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();
// TODO REVIEW should we use an adapter method for this, e.g. like handleResponse?
Copy link
Contributor Author

@pixelhandler pixelhandler Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on this topic, should the ability to handle the abort error live on the adapter?

try {
  error = adapter.handleAbort(
    responseData.status,
    responseData.headers,
    responseData.errorThrown || '',
    requestData
  );
} catch (e) {
  error = e;
}

function handleAbort(requestData, responseData) {
let msg = `Request failed: ${requestData.method} ${requestData.url} ${requestData.errorThrown || ''}`;
let errors = [{ title: 'Adapter Error', detail: msg.trim(), status: responseData.status }];
return new AbortError(errors);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this error with the url, and error response if available would be much better.

Currently we only use new AbortError();

@pixelhandler pixelhandler force-pushed the include-request-response-info-with-abort-error branch from 5e8183f to c76d07c Compare September 14, 2018 22:10
addon/adapters/rest.js Show resolved Hide resolved
let { status } = responseData;
let msg = `Request failed: ${method} ${url} ${errorThrown || ''}`;
let errors = [{ title: 'Adapter Error', detail: msg.trim(), status }];
return new AbortError(errors);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this error with the url, and error response if available would be much better.

Currently we only use new AbortError();

- Add test for capturing error details
@pixelhandler pixelhandler force-pushed the include-request-response-info-with-abort-error branch from 755bc27 to c0eb4d8 Compare September 15, 2018 00:37
@runspired
Copy link
Contributor

Thanks so much!

@runspired runspired merged commit 60f7448 into emberjs:master Sep 15, 2018
@pixelhandler
Copy link
Contributor Author

Likewise thank you @runspired

@pixelhandler
Copy link
Contributor Author

pixelhandler commented Oct 15, 2018

@runspired any chance this one can be merged into an LTS?

In v3.5 release...

Our app is not able to upgrade to 3.5 and just dies on loading, We're on 3.4

@pixelhandler pixelhandler deleted the include-request-response-info-with-abort-error branch October 15, 2018 22:48
pixelhandler pushed a commit to pixelhandler/data that referenced this pull request Oct 15, 2018
…ponse-info-with-abort-error

Include request/response info with Abort error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants