features, cleanup and bug fixes #26
1 changed files with 2 additions and 22 deletions
remove ResponseError impl from type that is never a top-level error
commit
1603db6ab7
|
|
@ -46,20 +46,12 @@ impl ResponseError for SaveError {
|
|||
| SaveError::Url(_)
|
||||
| SaveError::Runtime(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
SaveError::AlreadyExists => StatusCode::CONFLICT,
|
||||
SaveError::Email(inner) => inner.status_code(),
|
||||
SaveError::Email(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
fn error_response(&self) -> HttpResponse<BoxBody> {
|
||||
let status_code = self.status_code();
|
||||
match self {
|
||||
SaveError::AlreadyExists => default_error_response(self, status_code),
|
||||
SaveError::IO(inner) => default_error_response(inner, status_code),
|
||||
SaveError::Persist(inner) => default_error_response(inner, status_code),
|
||||
SaveError::Serialize(inner) => default_error_response(inner, status_code),
|
||||
SaveError::Url(inner) => default_error_response(inner, status_code),
|
||||
SaveError::Email(inner) => inner.error_response(),
|
||||
SaveError::Runtime(inner) => default_error_response(inner, status_code),
|
||||
}
|
||||
default_error_response(self, status_code)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -72,18 +64,6 @@ pub(crate) enum EmailError {
|
|||
Template(#[from] handlebars::RenderError),
|
||||
}
|
||||
|
||||
impl ResponseError for EmailError {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
// technically the email address could be invalid,
|
||||
// but an un-parsable email address should have been caught at form validation time
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
}
|
||||
fn error_response(&self) -> HttpResponse<BoxBody> {
|
||||
let status_code = self.status_code();
|
||||
default_error_response(self, status_code)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub(crate) enum DeleteError {
|
||||
#[error("{0}")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue