Pass error to the transition failed handlers

The error is required for error reporting but was previously ignored.
Added tests for this behavior.
Handle exceptions in prereqs

Added handling of exceptions that may be thrown out of `enterPrereqs` or
`exitPrereqs`. Added tests for these cases.