-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[BUGFIX beta] Add ducktyping of AdapterError
#4111
Conversation
Tests were failing locally even when reverting so I figured I'd try pushing anyway. Will dig back in tomorrow morning. Would like feedback on direction as well /cc @rwjblue |
Using flags seems better than using instance of to me... |
AdapterError
and InvalidError
AdapterError
Slightly confusing, there are 2 different definitions for |
@tchak is this an oversite or do we need 2 definitions for |
@danmcclain Is this something that should be considered a |
@bmac Here are the 2 different definitions: data/addon/-private/adapters/errors.js Lines 85 to 90 in 209326f
Model InvalidError: Also, I can label as such, I didn't give it a label, as I was unsure what you would want it to be |
@bmac I think |
AdapterError
AdapterError
I am not a big fan of this. I started some work to make it easy to inherit from The two definitions of |
@tchak Using |
@@ -853,7 +853,7 @@ export default Adapter.extend(BuildURLMixin, { | |||
requestData | |||
); | |||
|
|||
if (response instanceof AdapterError) { | |||
if (response.isAdapterError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should likely be response && response.isAdapterError
in case response
is undefined / null.
@danmcclain @rwjblue added one final comment. Once that is fixed this pr should be ready to be merged. |
@bmac will update shortly 👍🏼 |
There are `instanceof` checks for `AdapterError` this removes them in favor of checking for a property on the error, `isAdapterError` appears on all errors that use `AdapterError` as the base.
[BUGFIX beta] Add ducktyping of `AdapterError`
Thanks @danmcclain |
@rwjblue ok. I see quite well why |
There are
instanceof
checks forAdapterError
; this removes it in favor of checking for a property on the error.isAdapterError
appears on all errors that useAdapterError
as the base.This PR is looking to avoid the need to import private errors in fastboot to keep the same code flow in the ajax method used in node land, related PR: ember-fastboot/ember-cli-fastboot#95