0008 - Add Ajax error handling ADR#9
Conversation
| When handled, [growl](http://ksylvest.github.io/jquery-growl/) is often used this way: | ||
|
|
||
| ```javascript | ||
| if (response.responseJSON && response.responseJSON.message) { | ||
| $.growl.error({message: response.responseJSON.message}); | ||
| } | ||
| ``` |
There was a problem hiding this comment.
What we could do is adding an i18n message on errors not returning JSON, if this is possible
|
|
||
| ## Context | ||
|
|
||
| We need to define a way to handle Ajax calls errors. |
There was a problem hiding this comment.
We don't need to define a way to handle ajax calls errors. We need to define ajax calls errors 😅
Since we use jQuery: have a look at https://api.jquery.com/ajaxerror/
With this you can handle all ajax errors by a generic check.
if response has message:
message = json message;
else:
message = generic message;
fi
if growl:
use growl(message)
else:
console.log?
fi
There was a problem hiding this comment.
That should be done on every calls (or at least on every "main" actions to avoid spamming since sometimes an actions has more than 3 calls)
|
It looks like this ADR is kindof stale. We need to simply choose one solution and start using it everywhere. I suggest @eternoendless chooses the solution to use and then we can complete merge this ADR. |
|
@atomiix if you are OK, maybe we should close this? we were not able to manage this topic until a vote |
No description provided.