Conversation
| $httpProvider.interceptors.push('errorHttpInterceptor'); | ||
| }]) | ||
| .run(['$window', 'error', function ($window, error) { | ||
| $window.onerror = onError; |
There was a problem hiding this comment.
We should be able to avoid the global here. And if we can't, we should give it an odca prefix just in case.
There was a problem hiding this comment.
Not sure what you mean, the onerror? I'm just hooking into the browser's global error handler.
app/components/common/error/index.js
Outdated
| return { | ||
| responseError: function errorHttpInterceptor (response) { | ||
| //TODO maybe check response.status and redirect to 404? | ||
| error(new Error(response.statusText)); |
There was a problem hiding this comment.
Be sure to rethrow the error or return a rejected promise here. Otherwise, errors get treated as successes in subsequent functions in the promise chain. It's effectively a catch. https://docs.angularjs.org/api/ng/service/$http
There was a problem hiding this comment.
Ah, good point. In that case, I'm thinking we don't need any handler here at all, that way the default http handler will just throw the error and the global handler will catch it.
Fixes #171
Still testing this out in development.
Handles the following error scenarios
$httpwindow.onerrorProvides a service
error, to display the message or via theodca.error-messageevent.