@@ -624,21 +624,39 @@ export interface IHookRegistry {
624
624
onSuccess ( matchCriteria : HookMatchCriteria , callback : TransitionHookFn , options ?: HookRegOptions ) : Function ;
625
625
626
626
/**
627
- * Registers a [[TransitionHookFn]], called after a successful transition completed .
627
+ * Registers a [[TransitionHookFn]], called after a transition has errored .
628
628
*
629
- * Registers a transition lifecycle hook, which is invoked after a transition successfully completes .
629
+ * Registers a transition lifecycle hook, which is invoked after a transition has been rejected for any reason .
630
630
*
631
631
* See [[TransitionHookFn]] for the signature of the function.
632
632
*
633
633
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
634
634
*
635
635
* ### Lifecycle
636
636
*
637
- * `onError` hooks are chained off the Transition's promise (see [[Transition.promise]]).
638
- * If the Transition fails and its promise is rejected, then the `onError` hooks are invoked.
639
- * Since these hooks are run after the transition is over, their return value is ignored.
637
+ * The `onError` hooks are chained off the Transition's promise (see [[Transition.promise]]).
638
+ * If a Transition fails, its promise is rejected and the `onError` hooks are invoked.
640
639
* The `onError` hooks are invoked in priority order.
641
640
*
641
+ * Since these hooks are run after the transition is over, their return value is ignored.
642
+ *
643
+ * A transition "errors" if it was started, but failed to complete (for any reason).
644
+ * A *non-exhaustive list* of reasons a transition can error:
645
+ *
646
+ * - A transition was cancelled because a new transition started while it was still running
647
+ * - A transition was cancelled by a Transition Hook returning false
648
+ * - A transition was redirected by a Transition Hook returning a [[TargetState]]
649
+ * - A transition was invalid because the target state/parameters are not valid
650
+ * - A transition was ignored because the target state/parameters are exactly the current state/parameters
651
+ * - A Transition Hook or resolve function threw an error
652
+ * - A Transition Hook returned a rejected promise
653
+ * - A resolve function returned a rejected promise
654
+ *
655
+ * To check the failure reason, inspect the return value of [[Transition.error]].
656
+ *
657
+ * Note: `onError` should be used for targeted error handling, or error recovery.
658
+ * For simple catch-all error reporting, use [[StateService.defaultErrorHandler]].
659
+ *
642
660
* ### Return value
643
661
*
644
662
* Since the Transition is already completed, the hook's return value is ignored
0 commit comments