ApiException class
An exception that carries an HTTP status code and message.
Throw this from handlers or validators to return a specific HTTP error response rather than a generic 500. For example:
throw ApiException(404, 'User not found');
throw ApiException(422, 'Invalid email format');
- Implemented types
Constructors
- ApiException(int statusCode, String message)
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
A human-readable error message included in the response body.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
The HTTP status code to return (e.g., 400, 404, 422).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited