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

Fix bad json error handling, test error states #56

Merged
merged 2 commits into from
Mar 15, 2017

Conversation

demersus
Copy link
Contributor

From my testing with jQuery: jQuery will trigger the error callback with an untouched jqXHR object, a statusText of 'parseerror', and a SyntaxError - when it can't parse the response json.

This PR does a couple things:

  1. it mimics the way jQuery would respond when it can't parse json
  2. it preserves the original responseText, since the error argument will contain the stacktrace, and the responseText is sometimes essential to understanding what went wrong.
  3. Tests for error states to ensure expected arguments and context are passed to error handlers

@demersus
Copy link
Contributor Author

This is similar to: #46 but from my testing, the error callback is triggered, not the success callback (with jQuery)

* Return original responseText in errors.  Stack trace is available in
error (3rd argument)
@demersus demersus force-pushed the error-tests-parse-error branch from 62fa832 to 360ed15 Compare March 14, 2017 17:03
@alanclarke
Copy link
Contributor

👍 thanks @demersus!

@alanclarke alanclarke merged commit 9c011fc into najaxjs:master Mar 15, 2017
demersus added a commit to demersus/fastboot that referenced this pull request Mar 15, 2017
The upgrade contains an important fix for catching errors when an
assumed json endpoint returns html.  This can happen when the gateway
times out.

See: najaxjs/najax#56
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