pub enum FrameworkError {
ServiceNotFound {
type_name: &'static str,
},
ParamError {
param_name: String,
},
ValidationError {
field: String,
message: String,
},
Database(String),
Internal {
message: String,
},
Domain {
message: String,
status_code: u16,
},
Validation(ValidationErrors),
Unauthorized,
ModelNotFound {
model_name: String,
},
ParamParse {
param: String,
expected_type: &'static str,
},
}Expand description
Framework-wide error type
This enum represents all possible errors that can occur in the framework.
It implements From<FrameworkError> for Response so errors can be propagated
using the ? operator in controller handlers.
§Example
use ferro_rs::{App, FrameworkError, Response};
pub async fn index(_req: Request) -> Response {
let service = App::resolve::<MyService>()?; // Returns FrameworkError on failure
// ...
}§Automatic Error Conversion
FrameworkError implements From for common error types, allowing seamless
use of the ? operator:
use ferro_rs::{DB, FrameworkError};
use sea_orm::ActiveModelTrait;
pub async fn create_todo() -> Result<Todo, FrameworkError> {
let todo = new_todo.insert(&*DB::get()?).await?; // DbErr converts automatically!
Ok(todo)
}Variants§
ServiceNotFound
Service not found in the dependency injection container
ParamError
Parameter extraction failed (missing or invalid parameter)
ValidationError
Validation error
Database(String)
Database error
Internal
Generic internal server error
Domain
Domain/application error with custom status code
Used for user-defined domain errors that need custom HTTP status codes.
Validation(ValidationErrors)
Form validation errors (422 Unprocessable Entity)
Contains multiple field validation errors in Laravel/Inertia format.
Authorization failed (403 Forbidden)
Used when FormRequest::authorize() returns false.
ModelNotFound
Model not found (404 Not Found)
Used when route model binding fails to find the requested resource.
ParamParse
Parameter parse error (400 Bad Request)
Used when a path parameter cannot be parsed to the expected type.
Implementations§
Source§impl FrameworkError
impl FrameworkError
Sourcepub fn service_not_found<T: ?Sized>() -> Self
pub fn service_not_found<T: ?Sized>() -> Self
Create a ServiceNotFound error for a given type
Sourcepub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
Create a ValidationError
Sourcepub fn domain(message: impl Into<String>, status_code: u16) -> Self
pub fn domain(message: impl Into<String>, status_code: u16) -> Self
Create a Domain error with custom status code
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Get the HTTP status code for this error
Sourcepub fn validation_errors(errors: ValidationErrors) -> Self
pub fn validation_errors(errors: ValidationErrors) -> Self
Create a Validation error from ValidationErrors struct
Sourcepub fn model_not_found(name: impl Into<String>) -> Self
pub fn model_not_found(name: impl Into<String>) -> Self
Create a ModelNotFound error (404)
Sourcepub fn param_parse(
param: impl Into<String>,
expected_type: &'static str,
) -> Self
pub fn param_parse( param: impl Into<String>, expected_type: &'static str, ) -> Self
Create a ParamParse error (400)
Sourcepub fn hint(&self) -> Option<String>
pub fn hint(&self) -> Option<String>
Returns an actionable hint guiding the developer toward a fix.
Hints are included in JSON error responses during development to help
developers quickly resolve common issues. Variants with user-provided
messages (Internal, Domain) or self-describing content (Validation,
ValidationError) return None.
Trait Implementations§
Source§impl Clone for FrameworkError
impl Clone for FrameworkError
Source§fn clone(&self) -> FrameworkError
fn clone(&self) -> FrameworkError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FrameworkError
impl Debug for FrameworkError
Source§impl Display for FrameworkError
impl Display for FrameworkError
Source§impl Error for FrameworkError
impl Error for FrameworkError
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
use the Display impl or to_string()
Source§impl From<AppError> for FrameworkError
impl From<AppError> for FrameworkError
Source§impl From<DbErr> for FrameworkError
impl From<DbErr> for FrameworkError
Source§impl From<FrameworkError> for HttpResponse
Auto-convert FrameworkError to HttpResponse
impl From<FrameworkError> for HttpResponse
Auto-convert FrameworkError to HttpResponse
This enables using the ? operator in controller handlers to propagate
framework errors as appropriate HTTP responses.
When a hint is available (via FrameworkError::hint()), the JSON response
includes a "hint" field with actionable guidance for the developer.
Source§fn from(err: FrameworkError) -> HttpResponse
fn from(err: FrameworkError) -> HttpResponse
Source§impl From<ParamError> for FrameworkError
impl From<ParamError> for FrameworkError
Source§fn from(err: ParamError) -> FrameworkError
fn from(err: ParamError) -> FrameworkError
Auto Trait Implementations§
impl Freeze for FrameworkError
impl RefUnwindSafe for FrameworkError
impl Send for FrameworkError
impl Sync for FrameworkError
impl Unpin for FrameworkError
impl UnsafeUnpin for FrameworkError
impl UnwindSafe for FrameworkError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.