registerException function
Registers an exception that was caught for the current test.
Implementation
void registerException(
Object error, [
StackTrace stackTrace = StackTrace.empty,
]) {
// 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);
}