Struct lambda_sqs::Diagnostic
source · pub struct Diagnostic {
pub error_type: String,
pub error_message: String,
}Expand description
Diagnostic information about an error.
Diagnostic is automatically derived for some common types,
like boxed types that implement Error.
If you use an error type which comes from a external crate like anyhow,
you need convert it to common types like Box<dyn std::error::Error>.
See the examples for more details.
error_type is derived from the type name of
the original error with std::any::type_name as a fallback, which may
not be reliable for conditional error handling.
To get more descriptive error_type fields, you can implement From for your error type.
That gives you full control on what the error_type is.
Example:
use lambda_runtime::{Diagnostic, Error, LambdaEvent};
#[derive(Debug)]
struct ErrorResponse(&'static str);
impl From<ErrorResponse> for Diagnostic {
fn from(error: ErrorResponse) -> Diagnostic {
Diagnostic {
error_type: "MyError".into(),
error_message: error.0.to_string(),
}
}
}
async fn function_handler(_event: LambdaEvent<()>) -> Result<(), ErrorResponse> {
Err(ErrorResponse("this is an error response"))
}Fields§
§error_type: Stringerror_type is the type of exception or error returned by the function.
Use this field to categorize the different kinds of errors that your function
might experience.
In standard implementations, error_type is derived from the type name of the original error with
std::any::type_name, however this is not descriptive enough for an error type.
Implement your own Into<Diagnostic> to return a more descriptive error type.
error_message: Stringerror_message is a string expression of the error.
In standard implementations, it’s the output from the Display
implementation of the original error.
Trait Implementations§
source§impl Clone for Diagnostic
impl Clone for Diagnostic
source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Diagnostic
impl Debug for Diagnostic
source§impl<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Diagnostic, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Diagnostic, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<&'static str> for Diagnostic
impl From<&'static str> for Diagnostic
source§fn from(value: &'static str) -> Diagnostic
fn from(value: &'static str) -> Diagnostic
source§impl From<DeserializeError> for Diagnostic
impl From<DeserializeError> for Diagnostic
source§fn from(value: DeserializeError) -> Diagnostic
fn from(value: DeserializeError) -> Diagnostic
source§impl From<Error> for Diagnostic
impl From<Error> for Diagnostic
source§fn from(value: Error) -> Diagnostic
fn from(value: Error) -> Diagnostic
source§impl From<Infallible> for Diagnostic
impl From<Infallible> for Diagnostic
source§fn from(value: Infallible) -> Diagnostic
fn from(value: Infallible) -> Diagnostic
source§impl From<String> for Diagnostic
impl From<String> for Diagnostic
source§fn from(value: String) -> Diagnostic
fn from(value: String) -> Diagnostic
source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
source§fn eq(&self, other: &Diagnostic) -> bool
fn eq(&self, other: &Diagnostic) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for Diagnostic
impl Serialize for Diagnostic
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnwindSafe for Diagnostic
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)