Skip to content

Commit 45aba38

Browse files
committed
feat: [#802] new errors
1 parent 1e992ba commit 45aba38

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub enum ServiceError {
2222

2323
#[display("Email is required")] //405j
2424
EmailMissing,
25+
#[display("A verified email is required")]
26+
VerifiedEmailMissing,
2527
#[display("Please enter a valid email address")] //405j
2628
EmailInvalid,
2729

@@ -60,6 +62,9 @@ pub enum ServiceError {
6062
#[display("Passwords don't match")]
6163
PasswordsDontMatch,
6264

65+
#[display("Couldn't send new password to the user")]
66+
FailedToSendResetPassword,
67+
6368
/// when the a username is already taken
6469
#[display("Username not available")]
6570
UsernameTaken,
@@ -288,6 +293,7 @@ pub fn http_status_code_for_service_error(error: &ServiceError) -> StatusCode {
288293
ServiceError::PasswordTooShort => StatusCode::BAD_REQUEST,
289294
ServiceError::PasswordTooLong => StatusCode::BAD_REQUEST,
290295
ServiceError::PasswordsDontMatch => StatusCode::BAD_REQUEST,
296+
ServiceError::FailedToSendResetPassword => StatusCode::INTERNAL_SERVER_ERROR,
291297
ServiceError::UsernameTaken => StatusCode::BAD_REQUEST,
292298
ServiceError::UsernameInvalid => StatusCode::BAD_REQUEST,
293299
ServiceError::EmailTaken => StatusCode::BAD_REQUEST,
@@ -316,6 +322,7 @@ pub fn http_status_code_for_service_error(error: &ServiceError) -> StatusCode {
316322
ServiceError::TagAlreadyExists => StatusCode::BAD_REQUEST,
317323
ServiceError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
318324
ServiceError::EmailMissing => StatusCode::NOT_FOUND,
325+
ServiceError::VerifiedEmailMissing => StatusCode::NOT_FOUND,
319326
ServiceError::FailedToSendVerificationEmail => StatusCode::INTERNAL_SERVER_ERROR,
320327
ServiceError::WhitelistingError => StatusCode::INTERNAL_SERVER_ERROR,
321328
ServiceError::DatabaseError => StatusCode::INTERNAL_SERVER_ERROR,

0 commit comments

Comments
 (0)