Closed rahij closed 5 months ago
Creating an internal or service error currently has the following signature:
pub fn service<E, T>(cause: E, error_type: T) -> Error where E: Into<Box<dyn error::Error + Sync + Send>>, T: ErrorType + Serialize, { }
Errors defined in conjure generate objects which only implement ErrorType. Are users expected to create their own std::error::Error so that they can call this method?
ErrorType
Yes, though many types implement Into<Box<dyn Error>>. For example, &'static str and String do, so you can do things like:
Into<Box<dyn Error>>
&'static str
String
return Err(Error::service("you can't divide by 0", DivideByZeroError::new()));
What happened?
Creating an internal or service error currently has the following signature:
Errors defined in conjure generate objects which only implement
ErrorType
. Are users expected to create their own std::error::Error so that they can call this method?