Removed used Generic error response
This commit is contained in:
parent
ea2cccb024
commit
cc22a56538
@ -31,37 +31,4 @@ impl<'r> Responder<'r> for DbResponse {
|
||||
.raw_header("db-error", self.err_msg)
|
||||
.ok()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic error that we can both serialize and return as an API response
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResponseErr {
|
||||
pub msg: &'static str,
|
||||
pub status: i16,
|
||||
pub err_type: &'static str,
|
||||
}
|
||||
|
||||
pub type ResponseResult<T, ResponseErr> = std::result::Result<T, ResponseErr>;
|
||||
|
||||
impl fmt::Display for ResponseErr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, self.err_type)
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for ResponseErr {
|
||||
fn source(&self) -> Option(&(dyn error::Error + 'static)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for ResponseErr {
|
||||
fn respond_to(self, _:&Request) -> response::Result<'r> {
|
||||
Response::build()
|
||||
.status(self.status)
|
||||
.raw_header(self.err_type, self.msg)
|
||||
.ok()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user