Throws class final
Annotation that declares a function, method, or getter may throw one or more exceptions at runtime.
This annotation is intended to be enforced by the annotations analyzer
plugin, which provides the handle_throwing_invocations lint rule.
Usage:
@Throws({FormatException})
void parseData(String input) {
// may throw FormatException
}
@Throws({MyDomainError, StateError})
Future<void> processData() async {
// may throw MyDomainError or StateError
}
Note: This annotation does not change runtime semantics. It is purely a static analysis hint to help developers handle potential exceptions.
When a function annotated with @Throws is called, the analyzer plugin
will warn if the call is not wrapped in an appropriate try-catch block
or otherwise handled.
- Annotations
-
- @Target.new({TargetKind.function, TargetKind.method, TargetKind.getter})
Constructors
Properties
-
exceptions
→ Set<
Type> -
The set of exception types that may be thrown by the annotated declaration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited