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:
20
src/error.rs
20
src/error.rs
@@ -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 {
|
||||
|
Reference in New Issue
Block a user