AuthError class
Represents an authentication error.
The AuthError class contains error information including a machine-readable error code, human-readable message, and optional details.
Error Handling
final response = await authClient.signIn.email(
email: email,
password: password,
);
if (response.isError) {
final error = response.error!;
print('Code: ${error.code}');
print('Message: ${error.message}');
if (error.details != null) {
print('Details: ${error.details}');
}
}
See also:
- AuthResponse for response wrapping
- BetterAuthClient for error-generating operations
Constructors
-
AuthError({required String code, required String message, Map<
String, dynamic> ? details}) - Creates a new AuthError instance.
- AuthError.fromDio(DioException exception)
-
Creates an AuthError from a
DioException.factory -
AuthError.validation(Map<
String, dynamic> errors) -
Creates a validation error with field-specific details.
factory
Properties
- code → String
-
Error code for programmatic handling.
final
-
details
→ Map<
String, dynamic> ? -
Additional error details.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- message → String
-
Human-readable error message.
final
- 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.
override
Static Properties
- emailAlreadyExists ↔ AuthError
-
Error indicating email already exists.
getter/setter pair
- invalidCredentials ↔ AuthError
-
Error indicating invalid credentials.
getter/setter pair
- sessionExpired ↔ AuthError
-
Error indicating session has expired.
getter/setter pair
-
Error indicating unauthorized access.
getter/setter pair
- userNotFound ↔ AuthError
-
Error indicating user not found.
getter/setter pair