Catch more HTTP API errors

This commit is contained in:
Lucien Greathouse
2019-09-19 13:50:42 -07:00
parent 44a42a177a
commit aababf37a8
2 changed files with 36 additions and 31 deletions

View File

@@ -93,9 +93,25 @@ impl ErrorResponse {
details: details.into(),
}
}
pub fn bad_request<S: Into<String>>(details: S) -> Self {
Self {
kind: ErrorResponseKind::BadRequest,
details: details.into(),
}
}
pub fn internal_error<S: Into<String>>(details: S) -> Self {
Self {
kind: ErrorResponseKind::InternalError,
details: details.into(),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub enum ErrorResponseKind {
NotFound,
BadRequest,
InternalError,
}