LoggingExceptionHandler class
Mock implementation of ExceptionHandler that logs all exceptions for later processing.
class LoggingExceptionHandler implements ExceptionHandler { /** * All exceptions are stored here for later examining. */ final List<ExceptionWithStack> errors = []; call(error, stack, [reason]) { errors.add(new ExceptionWithStack(error, stack)); } /** * This method throws an exception if the errors is not empty. * It is recommended that this method is called on test tear-down * to verify that all exceptions have been processed. */ assertEmpty() { if (errors.length > 0) { throw new ArgumentError('Exception Logger not empty:\n$errors'); } } }
Implements
Properties
final List<ExceptionWithStack> errors #
All exceptions are stored here for later examining.
final List<ExceptionWithStack> errors = []
Methods
dynamic assertEmpty() #
This method throws an exception if the errors is not empty. It is recommended that this method is called on test tear-down to verify that all exceptions have been processed.
assertEmpty() { if (errors.length > 0) { throw new ArgumentError('Exception Logger not empty:\n$errors'); } }
dynamic call(error, stack, [reason]) #
Delegate uncaught exception for central error handling.
- error The error which was caught.
- stack The stacktrace.
- reason Optional contextual information for the error.
docs inherited from ExceptionHandler
call(error, stack, [reason]) { errors.add(new ExceptionWithStack(error, stack)); }