registerException function
Registers an exception that was caught for the current test.
Implementation
void registerException(error, [StackTrace stackTrace]) {
// This will usually forward directly to [Invoker.current.handleError], but
// going through the zone API allows other zones to consistently see errors.
Zone.current.handleUncaughtError(error, stackTrace);
}