pub struct ClassifiedError {
pub category: ErrorCategory,
pub message: String,
pub suggestion: String,
}Expand description
A classified error with category, message, and actionable suggestion.
This struct wraps an error message with its classification and provides helpful suggestions for resolving the issue.
Fields§
§category: ErrorCategoryThe error category
message: StringThe original error message
suggestion: StringAn actionable suggestion for resolving the error
Implementations§
Source§impl ClassifiedError
impl ClassifiedError
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
Creates a new classified error from an error message.
§Arguments
message- The error message to classify
§Examples
use camgrab_core::error::ClassifiedError;
let error = ClassifiedError::new("401 Unauthorized");
assert_eq!(error.category, camgrab_core::error::ErrorCategory::Auth);
assert!(error.suggestion.contains("username and password"));Sourcepub fn with_category(
category: ErrorCategory,
message: impl Into<String>,
) -> Self
pub fn with_category( category: ErrorCategory, message: impl Into<String>, ) -> Self
Creates a new classified error with an explicit category.
§Arguments
category- The error categorymessage- The error message
§Examples
use camgrab_core::error::{ClassifiedError, ErrorCategory};
let error = ClassifiedError::with_category(
ErrorCategory::NetworkTimeout,
"Connection timed out after 30s"
);
assert_eq!(error.category, ErrorCategory::NetworkTimeout);Sourcepub fn with_custom_suggestion(
category: ErrorCategory,
message: impl Into<String>,
suggestion: impl Into<String>,
) -> Self
pub fn with_custom_suggestion( category: ErrorCategory, message: impl Into<String>, suggestion: impl Into<String>, ) -> Self
Creates a new classified error with a custom suggestion.
§Arguments
category- The error categorymessage- The error messagesuggestion- A custom suggestion
Trait Implementations§
Source§impl Clone for ClassifiedError
impl Clone for ClassifiedError
Source§fn clone(&self) -> ClassifiedError
fn clone(&self) -> ClassifiedError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClassifiedError
impl Debug for ClassifiedError
Source§impl<'de> Deserialize<'de> for ClassifiedError
impl<'de> Deserialize<'de> for ClassifiedError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ClassifiedError
impl Display for ClassifiedError
Source§impl Error for ClassifiedError
impl Error for ClassifiedError
1.30.0 · 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 PartialEq for ClassifiedError
impl PartialEq for ClassifiedError
Source§impl Serialize for ClassifiedError
impl Serialize for ClassifiedError
impl Eq for ClassifiedError
impl StructuralPartialEq for ClassifiedError
Auto Trait Implementations§
impl Freeze for ClassifiedError
impl RefUnwindSafe for ClassifiedError
impl Send for ClassifiedError
impl Sync for ClassifiedError
impl Unpin for ClassifiedError
impl UnsafeUnpin for ClassifiedError
impl UnwindSafe for ClassifiedError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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> 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.