recordException method
Return the 'last' error if any.
Implementation
Exception? recordException([Object? error, StackTrace? stack]) {
// Retrieved the currently recorded exception
var ex = _recException;
if (error == null) {
// Once retrieved, empty this of the exception.
_recException = null;
_stackTrace = null;
} else {
if (error is! Exception) {
_recException = Exception(error.toString());
} else {
_recException = error;
}
// Return the current exception
ex = _recException;
_stackTrace = stack;
}
return ex;
}