1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 17:07:01 +02:00

add custom ExceptError

This commit is contained in:
Nikolay Kim
2017-11-19 17:51:14 -10:00
parent 78d8d21196
commit 72edd75eab
4 changed files with 25 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ pub use cookie::{ParseError as CookieParseError};
use body::Body;
use httpresponse::HttpResponse;
use httpcodes::{HTTPBadRequest, HTTPMethodNotAllowed};
use httpcodes::{HTTPBadRequest, HTTPMethodNotAllowed, HTTPExpectationFailed};
/// A specialized [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html)
/// for actix web operations
@@ -259,6 +259,24 @@ impl ErrorResponse for MultipartError {
}
}
/// Error during handling `Expect` header
#[derive(Fail, PartialEq, Debug)]
pub enum ExpectError {
/// Expect header value can not be converted to utf8
#[fail(display="Expect header value can not be converted to utf8")]
Encoding,
/// Unknown expect value
#[fail(display="Unknown expect value")]
UnknownExpect,
}
impl ErrorResponse for ExpectError {
fn error_response(&self) -> HttpResponse {
HTTPExpectationFailed.with_body("Unknown Expect")
}
}
/// Websocket handshake errors
#[derive(Fail, PartialEq, Debug)]
pub enum WsHandshakeError {