pub enum AuthError {
Show 20 variants
BadRequest(String),
InvalidRequest(String),
Validation(String),
InvalidCredentials,
Unauthenticated,
SessionNotFound,
Forbidden(String),
Unauthorized,
UserNotFound,
NotFound(String),
Conflict(String),
RateLimited,
NotImplemented(String),
Config(String),
Database(DatabaseError),
Serialization(Error),
Plugin {
plugin: String,
message: String,
},
Internal(String),
PasswordHash(String),
Jwt(Error),
}Expand description
Authentication framework error types.
Each variant maps to an HTTP status code via AuthError::status_code.
Use AuthError::into_response to produce a standardized JSON response
matching the better-auth OpenAPI spec: { "message": "..." }.
Variants§
BadRequest(String)
InvalidRequest(String)
Validation(String)
InvalidCredentials
Unauthenticated
SessionNotFound
Forbidden(String)
UserNotFound
NotFound(String)
Conflict(String)
RateLimited
NotImplemented(String)
Config(String)
Database(DatabaseError)
Serialization(Error)
Plugin
Internal(String)
PasswordHash(String)
Jwt(Error)
Implementations§
Source§impl AuthError
impl AuthError
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
HTTP status code for this error.
Sourcepub fn into_response(self) -> AuthResponse
pub fn into_response(self) -> AuthResponse
Convert this error into a standardized [AuthResponse] matching the
better-auth OpenAPI spec: { "message": "..." }.
Internal errors (500) use a generic message to avoid leaking details.
pub fn bad_request(message: impl Into<String>) -> Self
pub fn forbidden(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
pub fn conflict(message: impl Into<String>) -> Self
pub fn not_implemented(message: impl Into<String>) -> Self
pub fn plugin(plugin: &str, message: impl Into<String>) -> Self
pub fn config(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Trait Implementations§
Source§impl Error for AuthError
impl Error for AuthError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<DatabaseError> for AuthError
impl From<DatabaseError> for AuthError
Source§fn from(source: DatabaseError) -> Self
fn from(source: DatabaseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for AuthError
impl !RefUnwindSafe for AuthError
impl Send for AuthError
impl Sync for AuthError
impl Unpin for AuthError
impl !UnwindSafe for AuthError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP