mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 22:49:21 +02:00
Implement std::error::Error
for our custom errors
For allowing a more ergonomic use and better integration on the ecosystem, this adds the `std::error::Error` `impl` for our custom errors. We intent to drop this hand made code once `derive_more` finishes the addition of the Error derive support[1]. Until that is available, we need to live with that. 1. https://github.com/JelteF/derive_more/issues/92 Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
This commit is contained in:
@ -55,6 +55,8 @@ pub enum ConnectError {
|
||||
Io(io::Error),
|
||||
}
|
||||
|
||||
impl std::error::Error for ConnectError {}
|
||||
|
||||
impl From<actix_connect::ConnectError> for ConnectError {
|
||||
fn from(err: actix_connect::ConnectError) -> ConnectError {
|
||||
match err {
|
||||
@ -86,6 +88,8 @@ pub enum InvalidUrl {
|
||||
HttpError(http::Error),
|
||||
}
|
||||
|
||||
impl std::error::Error for InvalidUrl {}
|
||||
|
||||
/// A set of errors that can occur during request sending and response reading
|
||||
#[derive(Debug, Display, From)]
|
||||
pub enum SendRequestError {
|
||||
@ -115,6 +119,8 @@ pub enum SendRequestError {
|
||||
Body(Error),
|
||||
}
|
||||
|
||||
impl std::error::Error for SendRequestError {}
|
||||
|
||||
/// Convert `SendRequestError` to a server `Response`
|
||||
impl ResponseError for SendRequestError {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
@ -139,6 +145,8 @@ pub enum FreezeRequestError {
|
||||
Http(HttpError),
|
||||
}
|
||||
|
||||
impl std::error::Error for FreezeRequestError {}
|
||||
|
||||
impl From<FreezeRequestError> for SendRequestError {
|
||||
fn from(e: FreezeRequestError) -> Self {
|
||||
match e {
|
||||
|
Reference in New Issue
Block a user