errors 0.1.1

  • Readme
  • Changelog
  • Installing
  • 44

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();
    },
  );

[0.1.1] - 10.08.2019

  • Check error by name instead of type to cover edge cases.

[0.1.0] - 10.08.2019

  • Rethrow unhandled exceptions

[0.0.1] - 05.08.2019

  • Initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  errors: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:errors/errors.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:errors/errors.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and errors.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev<3.0.0
Dev dependencies
test any