Skip to content
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

Do not log TransitionRejection when the transition is ABORTED. #35

Closed
christopherthielen opened this issue Jan 31, 2017 · 5 comments
Closed
Milestone

Comments

@christopherthielen
Copy link
Member

if (error.type === RejectType.ABORTED) {
router.urlRouter.update();
// Fall through to default error handler
}
}
let errorHandler = this.defaultErrorHandler();
errorHandler(error);

    const rejectedTransitionHandler = (transition: Transition) => (error: any): Promise<any> => {
      if (error instanceof Rejection) {
        if (error.type === RejectType.IGNORED) {
          // Consider ignored `Transition.run()` as a successful `transitionTo`
          router.urlRouter.update();
          return services.$q.when(globals.current);
        }

        const detail: any = error.detail;
        if (error.type === RejectType.SUPERSEDED && error.redirected && detail instanceof TargetState) {
          // If `Transition.run()` was redirected, allow the `transitionTo()` promise to resolve successfully
          // by returning the promise for the new (redirect) `Transition.run()`.
          let redirect: Transition = transition.redirect(detail);
          return redirect.run().catch(rejectedTransitionHandler(redirect));
        }

        if (error.type === RejectType.ABORTED) {
          router.urlRouter.update();
          // Fall through to default error handler
        }
      }

      let errorHandler = this.defaultErrorHandler();
      errorHandler(error);

      return services.$q.reject(error);
    };

Current behavior is to log ABORTED rejections. Enough people have requested not to log, or been confused about how to mute them. We should change so we no longer fall through to the default error handler.

@christopherthielen
Copy link
Member Author

Closed by b07a24b

@seanhodges-tw
Copy link

Hi, issue angular-ui/ui-router#3302 refers here, should this fix apply to Angular 1 ui-router too?

@iwan-uschka
Copy link

I try to abort a transition without having an error log entry, i cannot use transition.abort() because i have to wait for a user input ("unsaved changes. continue?") so i return a promise.

      $transitions.onExit({exiting: 'main.settings'}, function(transition) {      
        var deferred = $q.defer();
        
        // promise testing
        $timeout(function(){
          // here i need to create a Rejection Object with type = RejectType.ABORTED 
          deferred.reject(false);
        }, 500);

        return deferred.promise;
      });

If i reject the promise, i get the error log entry, because i don't know, how to create a Rejection with a RejectType.ABORTED in my controller. How can i get access to the Rejection Class?

Or is there any other way, how i can abort a transition asynchronously and without creating a error log entry?

Using Angular 1.5.1 and ui-router 1.0.5.

Thanks

@DzmVasileusky
Copy link

@iwan-uschka It's because this fix was applied for Angular2-5 ui-router version only.

@ranst91
Copy link

ranst91 commented May 5, 2018

Any plans on fixing it for Angularjs?
Edit: The fact that it's yet to be fixed for AngularJS is quite annoying.
Meanwhile, I am using this:
$state.defaultErrorHandler((error) => angular.noop(error);
In my tests. Handle the error as you wish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants