throws 1.0.0-alpha copy "throws: ^1.0.0-alpha" to clipboard
throws: ^1.0.0-alpha copied to clipboard

An annotation for documenting and enforcing throwing functions.

[throws]

throws #

Annotations for documenting and enforcing throwing functions.

Install #

Add the dependency to your pubspec.yaml.

Usage #

Annotate functions that can throw:

@Throws('Parsing input failed', {FormatException, RangeError}) int parsePositiveInt(String input) { final value = int.parse(input); if (value < 0) { throw RangeError('Value must be non-negative'); } return value; }

You can also use the shorthand constant:

@throws void mightThrow() { throw Exception('x'); }

expectedErrors #

Use expectedErrors to declare the error types callers should handle. This is a set of Type literals.

@Throws('Reason', {StateError}) int singleValue(Iterable

3
likes
0
points
435
downloads

Publisher

verified publisherfeduke-nukem.dev

Weekly Downloads

An annotation for documenting and enforcing throwing functions.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on throws