Throws class
Annotation to indicate that a function, method, or constructor can throw an exception.
Use this annotation to mark functions that may throw exceptions, either
directly through throw statements or by calling other throwing functions
without catching their exceptions.
Example:
@throws
void riskyOperation() {
throw Exception('Something went wrong');
}
@throws
void callsRiskyOperation() {
riskyOperation(); // Can propagate exceptions
}
// No annotation needed - exceptions are caught
void safeOperation() {
try {
riskyOperation();
} catch (e) {
print('Handled: $e');
}
}
Constructors
- Throws()
-
const
Properties
- 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