Class GlobalExceptionHandler
java.lang.Object
ru.averkiev.socialmediaapi.exceptions.GlobalExceptionHandler
Класс отлавливает все исключения возникающие на уровне контроллера, для предоставления ошибки клиенту в виде JSON.
- Author:
- mrGreenNV
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ErrorResponse>
handleActivityFeedException
(ActivityFeedException afEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с лентой активности пользователя.org.springframework.http.ResponseEntity<ErrorResponse>
handleAuthException
(AuthException authEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с аутентификацией пользователя.org.springframework.http.ResponseEntity<ErrorResponse>
handleFriendshipRequestAcceptException
(FriendshipRequestAcceptException faEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с принятием запроса на дружбу.org.springframework.http.ResponseEntity<ErrorResponse>
handleFriendshipRequestCreateException
(FriendshipRequestCreateException frcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием запроса на дружбу.org.springframework.http.ResponseEntity<ErrorResponse>
handleFriendshipRequestNotFoundException
(FriendshipRequestNotFoundException fnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском запроса на дружбу.org.springframework.http.ResponseEntity<ErrorResponse>
handleImageNotFoundException
(ImageNotFoundException imfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском изображения.org.springframework.http.ResponseEntity<ErrorResponse>
handleMessageCreateException
(MessageCreateException mcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием сообщения.org.springframework.http.ResponseEntity<ErrorResponse>
handleMessageNotFoundException
(MessageNotFoundException mnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском сообщения.org.springframework.http.ResponseEntity<ErrorResponse>
handlePostCreationException
(PostCreationException pcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием поста.org.springframework.http.ResponseEntity<ErrorResponse>
handlePostNotFoundException
(PostNotFoundException pnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском поста.org.springframework.http.ResponseEntity<ErrorResponse>
handleSubscriberNotFoundException
(SubscriberNotFoundException snfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском подписчика.org.springframework.http.ResponseEntity<ErrorResponse>
handleSubscriptionNotFoundException
(SubscriptionNotFoundException snfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском подписки.org.springframework.http.ResponseEntity<ErrorResponse>
handleTokenNotFoundException
(TokenNotFoundException tnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском токена.org.springframework.http.ResponseEntity<ErrorResponse>
handleUserFriendNotFoundException
(UserFriendNotFoundException unfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском дружеской связи между пользователями.org.springframework.http.ResponseEntity<ErrorResponse>
handleUserNotFoundException
(UserNotFoundException unfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с лентой активности пользователя.org.springframework.http.ResponseEntity<ErrorResponse>
handleUserRegistrationException
(UserRegistrationException urEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с валидацией регистрацией пользователя.org.springframework.http.ResponseEntity<ErrorResponse>
handleValidationException
(org.springframework.web.bind.MethodArgumentNotValidException ex, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с валидацией пользовательских данных.
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleValidationException
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleValidationException(org.springframework.web.bind.MethodArgumentNotValidException ex, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с валидацией пользовательских данных.- Parameters:
ex
- ошибки при валидации данных.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleUserRegistrationException
@ExceptionHandler(UserRegistrationException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleUserRegistrationException(UserRegistrationException urEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с валидацией регистрацией пользователя.- Parameters:
urEx
- ошибка при регистрации пользователя.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleAuthException
@ExceptionHandler(AuthException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleAuthException(AuthException authEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с аутентификацией пользователя.- Parameters:
authEx
- ошибка при аутентификации пользователя.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleActivityFeedException
@ExceptionHandler(ActivityFeedException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleActivityFeedException(ActivityFeedException afEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с лентой активности пользователя.- Parameters:
afEx
- ошибка при аутентификации пользователя.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleUserNotFoundException
@ExceptionHandler(UserNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleUserNotFoundException(UserNotFoundException unfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с лентой активности пользователя.- Parameters:
unfEx
- ошибка при аутентификации пользователя.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleFriendshipRequestCreateException
@ExceptionHandler(FriendshipRequestCreateException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleFriendshipRequestCreateException(FriendshipRequestCreateException frcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием запроса на дружбу.- Parameters:
frcEx
- ошибка при создании запроса на дружбу.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleFriendshipRequestNotFoundException
@ExceptionHandler(FriendshipRequestNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleFriendshipRequestNotFoundException(FriendshipRequestNotFoundException fnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском запроса на дружбу.- Parameters:
fnfEx
- ошибка при поиске запроса на дружбу.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleFriendshipRequestAcceptException
@ExceptionHandler(FriendshipRequestAcceptException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleFriendshipRequestAcceptException(FriendshipRequestAcceptException faEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с принятием запроса на дружбу.- Parameters:
faEx
- ошибка при принятии запроса на дружбу.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleMessageCreateException
@ExceptionHandler(MessageCreateException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleMessageCreateException(MessageCreateException mcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием сообщения.- Parameters:
mcEx
- ошибка при создании сообщения.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleMessageNotFoundException
@ExceptionHandler(MessageNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleMessageNotFoundException(MessageNotFoundException mnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском сообщения.- Parameters:
mnfEx
- ошибка при поиске сообщения.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handlePostCreationException
@ExceptionHandler(PostCreationException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handlePostCreationException(PostCreationException pcEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с созданием поста.- Parameters:
pcEx
- ошибка при создании поста.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handlePostNotFoundException
@ExceptionHandler(PostNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handlePostNotFoundException(PostNotFoundException pnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском поста.- Parameters:
pnfEx
- ошибка при поиске поста.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleImageNotFoundException
@ExceptionHandler(ImageNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleImageNotFoundException(ImageNotFoundException imfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском изображения.- Parameters:
imfEx
- ошибка при поиске изображения.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleUserFriendNotFoundException
@ExceptionHandler(UserFriendNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleUserFriendNotFoundException(UserFriendNotFoundException unfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском дружеской связи между пользователями.- Parameters:
unfEx
- ошибка при поиске дружеской связи.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleTokenNotFoundException
@ExceptionHandler(TokenNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleTokenNotFoundException(TokenNotFoundException tnfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском токена.- Parameters:
tnfEx
- ошибка при поиске токена.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleSubscriptionNotFoundException
@ExceptionHandler(SubscriptionNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleSubscriptionNotFoundException(SubscriptionNotFoundException snfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском подписки.- Parameters:
snfEx
- ошибка при поиске подписки.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-
handleSubscriberNotFoundException
@ExceptionHandler(SubscriberNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleSubscriberNotFoundException(SubscriberNotFoundException snfEx, jakarta.servlet.http.HttpServletRequest request) Позволяет обработать ошибки связанные с поиском подписчика.- Parameters:
snfEx
- ошибка при поиске подписчика.request
- HTTP запрос.- Returns:
- ResponseEntity, содержащий информацию об ошибке.
-