Closed jrhorn424 closed 7 years ago
Should
this.store.unloadAll();
be invoke by a terminal then
handler? It looks like this code could run before the sign-out completes.
Could we debug the value of reason to better understand what's going on? i.e.
let errors = reason.errors;
let unauthorized = errors && errors.some((error) => error.status === '401');
console.log(reason); // or the ember equivalent.
Could we debug the value of reason to better understand what's going on?
@gaand That's a good suggestion.
It occurs to me that we should be handling errors at the individual route handler level, not at the application route. Error handling should be specific to each route, which should allow us to better flash error messages depending on the same status code across different routes.
So, for example, in the sign-in route, an error hook could inspect the status code and suggest: no account (sign up please), invalid username or password, or whatever. The sign-up route error hook could suggest: email already taken, invalid password, or whatever.
[should clearing the store] be invoke by a terminal then handler? It looks like this code could run before the sign-out completes.
Yes, it should. Possibly a finally
instead of then
.
finally
doesn't appear to be Promise/A+ compliant.
Many developers in 012 got this error when starting to work with Ember. Some of them even gave up using Ember because they couldn't Google for help. Why couldn't they Google for help? Because I wrote the code that's causing it: https://github.com/ga-wdi-boston/ember-auth/blob/master/app/application/route.js#L21
So far the solution has to been to comment out the error handler.
In the future, we need to make a decision about how we handle these errors. Do I re-throw? Do I handle more error cases? This will block inclusion of
ember-auth
inember-template
.