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

ajaxError implementation breaks Ember.js contract #59

Closed
rafalp opened this issue Jan 22, 2015 · 6 comments · Fixed by #62
Closed

ajaxError implementation breaks Ember.js contract #59

rafalp opened this issue Jan 22, 2015 · 6 comments · Fixed by #62
Assignees

Comments

@rafalp
Copy link

rafalp commented Jan 22, 2015

While Ember-Data ajaxError returns errored jqXHR (as documented), ember-django-adapter instead returns Error(jsonErrors['detail']); breaking contract and making any suffisticated error processing impossible due to no original error data with exception of "detail" message making it to application.

@rafalp rafalp changed the title ajaxError implementation is not api-compatibile with Ember.js ajaxError implementation breaks Ember.js contract Jan 22, 2015
@benkonrath
Copy link
Collaborator

Thanks for the bug report. There's definitely some inconsistency in our implementation and the comment in this adapter.

I looked at the active model adapter and it also returns the jqXHR instead of the an Error in this case (Error(jsonErrors['detail']);).

https://github.com/emberjs/data/blob/48c02654e8a524b390d1a28975416ee73f912d9e/packages/activemodel-adapter/lib/system/active_model_adapter.js#L124

I chose to parse the error that Django Rest Framework provides because I thought it would be more useful than returning the jqHXR. I'm definitely open to changing this but I just want to understand how this is normally used in Ember applications. Can you provide an example of something that you can't do with the current implementation? Or an example that shows the returning the jqXHR is better? Thanks.

@benkonrath benkonrath self-assigned this Jan 22, 2015
@rafalp
Copy link
Author

rafalp commented Jan 22, 2015

Can you provide an example of something that you can't do with the current implementation?

For startes I can't do what guide tells me I should be able to do:
http://emberjs.com/guides/routing/loading-and-error-substates/

Resources on ember.js forums show me that I should be able to do so:
http://discuss.emberjs.com/t/how-to-deal-with-route-when-model-gets-a-404/5283/2

I want to look into error within my ApplicationRouter error handler and thus make call between error404 page that will have search field, common links and suggestions about why user can't reach page, and error 403 that will actually display error message from server. There is also special kind of error 403 that happens when user is banned. In this case ban details are added to error JSON and I can notice that within 403 handling and render errror-banned template that will display this JSON.

Finally there is also special 0 status code which I would love to redirect to error 0 page explaining user that server connection has been lost.

@benkonrath
Copy link
Collaborator

Ok, I'll fix this. Thanks for the information.

@rafalp
Copy link
Author

rafalp commented Jan 22, 2015

👍 good man, thanks for working on this!

@benkonrath
Copy link
Collaborator

@rafalp Can you review the code and try out the fix in #62 to see if it's going to work for you? Thanks.

@rafalp
Copy link
Author

rafalp commented Jan 24, 2015

Yep, my Ember.js ApplicationRoute's error hook can now access error status and whole message. There's also error.status so 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants