errors 0.0.1 copy "errors: ^0.0.1" to clipboard
errors: ^0.0.1 copied to clipboard

outdated

Multi exception handler

errors #

Errors keeps a registry of all possible exceptions which could be encountered.

Many times several exceptions can occur, some common and some less common.

In order to handle these gracefully we will often want to react differently according to the nature of the error.

e.g. code might fail due to a http error and within the same block a disk could be full or even a legitimate user error could be thrown.

Quick example:

  Errors errors;
  SomeExceptionHandler someExceptionHandler = SomeExceptionHandler();
  AnotherExceptionHandler anotherExceptionHandler = AnotherExceptionHandler();
  
  final errors = Errors()
      ..addHandler(someExceptionHandler)
      ..addHandler(anotherExceptionHandler);
  
  // Instead of using try/catch blocks the exceptions are now 
  // automatically catched and the registered exception handlers will
  // handle the exceptions.
  
  errors.handleError(
    () {
      throw SomeException();
    },
  );

  errors.handleError(
    () {
      throw AnotherException();
    },
  );
1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Multi exception handler

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on errors