tildeio/router.js — pull request #126 by marcelerz (2014-07-28 18:14:49+00:00)
Title: Fix for incorrect handlerWithError parameter for rejected promise during redirect

When throwing an error in a redirect function of a handler, the error event reports "handlerWithError" as the next handler in the handlerInfos, not the current handler. This is caused by incrementing payload.resolveIndex before redirect() is called.
However, moving the incrementation after the redirect call introduces other problems since the redirect body expects the resolution of the handler to be completed. (For example the test "The router: transitionTo will soak up resolved all models of active transition, including present route's resolved model" would fail).
This fix is not really elegant, but it will fix this issue with minimal impact to other code.