Skip to content

Commit

Permalink
chore: add specific exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
markkovari committed Sep 7, 2024
1 parent b72571f commit 97cc96a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.greenfoxacademy.backend.config;

import com.greenfoxacademy.backend.errors.*;

import com.greenfoxacademy.backend.errors.CannotSendEmailException;
import com.greenfoxacademy.backend.errors.CannotUpdateUserException;
import com.greenfoxacademy.backend.errors.CannotVerifyUserError;
import com.greenfoxacademy.backend.errors.UnableToDeleteProfileError;
import com.greenfoxacademy.backend.errors.UserAlreadyExistsError;
import java.util.HashMap;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ResponseEntity<RegisterResponseDto> registerUser(
*/
@PostMapping("/login")
public ResponseEntity<LoginResponseDto> loginUser(@RequestBody LoginRequestDto loginRequestDto)
throws UserNotVerifiedException {
throws UserNotVerifiedException {
return ResponseEntity.status(HttpStatus.OK).body(userService.login(loginRequestDto));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.greenfoxacademy.backend.errors;

/**
* Error to throw when a user cannot be verified.
* <p>
* This error should be thrown when a user cannot be verified.
* </p>
*/
public class UserNotVerifiedException extends RuntimeException {
public UserNotVerifiedException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import com.greenfoxacademy.backend.dtos.ProfileUpdateResponseDto;
import com.greenfoxacademy.backend.dtos.RegisterRequestDto;
import com.greenfoxacademy.backend.dtos.RegisterResponseDto;
import com.greenfoxacademy.backend.errors.*;
import com.greenfoxacademy.backend.errors.CannotSendEmailException;
import com.greenfoxacademy.backend.errors.CannotUpdateUserException;
import com.greenfoxacademy.backend.errors.CannotVerifyUserError;
import com.greenfoxacademy.backend.errors.UnableToDeleteProfileError;
import com.greenfoxacademy.backend.errors.UserAlreadyExistsError;
import com.greenfoxacademy.backend.errors.UserNotVerifiedException;
import com.greenfoxacademy.backend.models.User;
import java.util.UUID;
import org.springframework.security.core.userdetails.UserDetailsService;
Expand Down

0 comments on commit 97cc96a

Please sign in to comment.