pub enum AppError {
Validation(String),
Unauthorized,
InvalidCredentials,
TokenError(String),
Forbidden(String),
AccountDeactivated,
NotFound(String),
Conflict(String),
RateLimited,
Database(String),
Crypto(String),
Internal(String),
}Expand description
Application-level error.
Each variant maps to a specific HTTP status code via ResponseError.
See module-level docs for usage guidelines.
Variants§
Validation(String)
Input validation failed (bad request payload, missing fields, format errors).
Authentication required but not provided / token missing.
InvalidCredentials
Provided credentials are invalid. Used uniformly for “email not found” AND “wrong password” to prevent username enumeration attacks.
TokenError(String)
Token expired, malformed, or revoked.
Forbidden(String)
User is authenticated but lacks the required role/permission.
AccountDeactivated
User account exists but is deactivated.
NOTE: returning a distinct error from InvalidCredentials may leak
account existence — security review needed for auth/login flow.
NotFound(String)
Resource not found (e.g., user by id, building by id).
Conflict(String)
Conflict (e.g., email already in use, ownership total > 100%).
RateLimited
Rate limit exceeded.
Database(String)
Database error (sqlx, connection, query). Internal — not surfaced verbatim to clients.
Crypto(String)
Cryptographic error (bcrypt, JWT signing).
Internal(String)
Catch-all for legacy Result<_, String> propagation.
Should be reduced over time as repositories migrate.
Implementations§
Trait Implementations§
Source§impl Error for AppError
impl Error for AppError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<String> for AppError
Transition convenience: convert legacy String errors from repositories
into AppError::Internal. Should be used sparingly via .map_err(AppError::from)
at the boundary; prefer dedicated variants when the error semantic is known.
impl From<String> for AppError
Transition convenience: convert legacy String errors from repositories
into AppError::Internal. Should be used sparingly via .map_err(AppError::from)
at the boundary; prefer dedicated variants when the error semantic is known.
Source§impl ResponseError for AppError
impl ResponseError for AppError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Auto Trait Implementations§
impl Freeze for AppError
impl RefUnwindSafe for AppError
impl Send for AppError
impl Sync for AppError
impl Unpin for AppError
impl UnsafeUnpin for AppError
impl UnwindSafe for AppError
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
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more