-
Notifications
You must be signed in to change notification settings - Fork 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
How to inject $error$ in 1.0.0-beta.1 #2866
Comments
#2860 completely opposite of what you were trying to do, but i guess it is the event you are looking for. |
Not sure if this question belongs here, but I'll do it anyway. How should I implement a default error handler? In my case I have a rejected promise in the resolve object that returns a string but I'm unable to get this string inside my $transitions.onError. Also tried $transitions.defaultErrorHandler with no luck. Can you guys help me please? Thanks! Edit: Nevermind!! I just found out that defaultErrorHandler was moved from $transitions to $state.
Keep up the good work! Can't wait for 1.0 release. =) |
+1 app.config(['$transitionsProvider', function($transitionsProvider) {
$transitionsProvider.onError({...}, function(transition) {
var error = transition.promise.$$state.value; // No idea if this is always going to be available at the time of invocation
console.error(error);
});
}]); EDIT: Found a slightly less ugly workaround for now: app.config(['$transitionsProvider', function($transitionsProvider) {
$transitionsProvider.onError({...}, function(transition) {
transition.promise.catch(function(error) {
console.error(error);
});
});
}]); |
I think this was an oversight in beta.1, sorry. in beta.2 we will expose the error as |
Note: a workaround: var redirect = function (transition) {
transition.promise.catch(function($error$) {
if ($error$ && $error$.status === 404) {
$state.go('assets');
}
});
}; |
In the last alpha I was able to access the error object in an onError hook through:
Now that injections are done through the
transition
parameter I tried:Which always produces unknown provider errors.
Is there a new way to get the error object?
The text was updated successfully, but these errors were encountered: