Enum Class ExceptionDetails

java.lang.Object
java.lang.Enum<ExceptionDetails>
diegosneves.github.conectardoacoes.adapters.rest.enums.ExceptionDetails
All Implemented Interfaces:
Serializable, Comparable<ExceptionDetails>, Constable

public enum ExceptionDetails extends Enum<ExceptionDetails>
A classe ExceptionDetails é uma enumeração que define várias mensagens de exceções. Cada mensagem corresponde a uma condição específica de validação ou erro que pode ocorrer durante as operações.
Since:
1.0.0
Author:
diegoneves
  • Enum Constant Details

    • TERM_NOT_FOUND

      public static final ExceptionDetails TERM_NOT_FOUND
    • CONSTRUCTOR_DEFAULT_UNDEFINED

      public static final ExceptionDetails CONSTRUCTOR_DEFAULT_UNDEFINED
    • REQUEST_VALIDATION_ERROR_MESSAGE

      public static final ExceptionDetails REQUEST_VALIDATION_ERROR_MESSAGE
    • CLASS_MAPPING_FAILURE

      public static final ExceptionDetails CLASS_MAPPING_FAILURE
    • SHELTER_CREATION_ERROR_MESSAGE

      public static final ExceptionDetails SHELTER_CREATION_ERROR_MESSAGE
    • INVALID_UUID_FORMAT_MESSAGE

      public static final ExceptionDetails INVALID_UUID_FORMAT_MESSAGE
    • RESPONSIBLE_USER_PROFILE_INVALID

      public static final ExceptionDetails RESPONSIBLE_USER_PROFILE_INVALID
    • EMAIL_NOT_FOUND_ERROR_MESSAGE

      public static final ExceptionDetails EMAIL_NOT_FOUND_ERROR_MESSAGE
    • RESPONSIBLE_USER_ALREADY_IN_USE

      public static final ExceptionDetails RESPONSIBLE_USER_ALREADY_IN_USE
    • EMAIL_ALREADY_IN_USE

      public static final ExceptionDetails EMAIL_ALREADY_IN_USE
    • USER_RESPONSIBLE_EMAIL_NOT_FOUND_ERROR

      public static final ExceptionDetails USER_RESPONSIBLE_EMAIL_NOT_FOUND_ERROR
    • ZIPCODE_RETRIEVAL_FAILURE

      public static final ExceptionDetails ZIPCODE_RETRIEVAL_FAILURE
    • DONATION_VALIDATION_ERROR

      public static final ExceptionDetails DONATION_VALIDATION_ERROR
    • DONOR_EMAIL_NOT_FOUND_ERROR_MESSAGE

      public static final ExceptionDetails DONOR_EMAIL_NOT_FOUND_ERROR_MESSAGE
    • EMPTY_DONATION_LIST

      public static final ExceptionDetails EMPTY_DONATION_LIST
    • RESPONSIBLE_EMAIL_NOT_ASSOCIATED_WITH_SHELTER

      public static final ExceptionDetails RESPONSIBLE_EMAIL_NOT_ASSOCIATED_WITH_SHELTER
    • INVALID_ID_MESSAGE

      public static final ExceptionDetails INVALID_ID_MESSAGE
    • SHELTER_ERROR_MESSAGE

      public static final ExceptionDetails SHELTER_ERROR_MESSAGE
    • ADDRESS_CREATION_ERROR

      public static final ExceptionDetails ADDRESS_CREATION_ERROR
    • ERROR_MAPPING_ADDRESS

      public static final ExceptionDetails ERROR_MAPPING_ADDRESS
    • MISSING_USER_ENTITY_REQUEST_ERROR_MESSAGE

      public static final ExceptionDetails MISSING_USER_ENTITY_REQUEST_ERROR_MESSAGE
    • INVALID_EMAIL_ERROR_MESSAGE

      public static final ExceptionDetails INVALID_EMAIL_ERROR_MESSAGE
    • USER_CREATION_FAILURE_MESSAGE

      public static final ExceptionDetails USER_CREATION_FAILURE_MESSAGE
    • USER_PROFILE_VALIDATION_FAILURE

      public static final ExceptionDetails USER_PROFILE_VALIDATION_FAILURE
    • REQUIRED_USER_ERROR_MESSAGE

      public static final ExceptionDetails REQUIRED_USER_ERROR_MESSAGE
    • ZIPCODE_INVALID_FAILURE

      public static final ExceptionDetails ZIPCODE_INVALID_FAILURE
    • DEPOSIT_VALIDATION_ERROR

      public static final ExceptionDetails DEPOSIT_VALIDATION_ERROR
  • Field Details

    • EXCEPTION_PREFIX

      public static final String EXCEPTION_PREFIX
      See Also:
    • term

      private final Integer term
    • message

      private final String message
    • httpStatus

      private final org.springframework.http.HttpStatus httpStatus
  • Constructor Details

    • ExceptionDetails

      private ExceptionDetails(Integer term, String message, org.springframework.http.HttpStatus httpStatus)
  • Method Details

    • values

      public static ExceptionDetails[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ExceptionDetails valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • formatErrorMessage

      public String formatErrorMessage(String message)
      Formata uma mensagem com a entrada fornecida e retorna a mensagem formatada.
      Parameters:
      message - A mensagem de entrada que será formatada.
      Returns:
      A mensagem após a formatação.
    • formatErrorMessage

      public String formatErrorMessage()
      Método responsável por formatar uma mensagem de erro.

      Esse método forma uma mensagem de erro por prefixar a string de termo com um prefixo de exceção definido e em seguida, concatenando a mensagem. Isso é típico de cenários onde você precisa gerar mensagens de erro personalizadas para exceções.

      Returns:
      a mensagem de erro formatada como uma string. A mensagem de erro retornada consiste no termo prefixado com o EXCEPTION_PREFIX seguido pela mensagem de erro original.
    • getStatusCodeValue

      public int getStatusCodeValue()
      Retorna o código de status HTTP associado ao erro.
      Returns:
      O código numérico do status HTTP relacionado com o erro.
    • getHttpStatusCode

      public org.springframework.http.HttpStatus getHttpStatusCode()
      Obtém o status HTTP associado ao erro.
      Returns:
      O código de status HTTP relacionado ao erro.
    • getExceptionDetails

      public static ExceptionDetails getExceptionDetails(Integer code)
      Obtem os detalhes da exceção pelo código correspondente.

      Este método percorre o enum ExceptionDetails, procura um elemento cujo campo 'term' seja igual ao código de entrada e retorna esse elemento. Se nenhum elemento for encontrado com o código fornecido, uma nova exceção DetailsFailureException é lançada com código de erro 1.

      Exemplo de Uso

      ExceptionDetails detail = getExceptionDetails(1001);

      Exceções Lançadas

      DetailsFailureException - Se o código fornecido não corresponder a nenhum 'term' do enum ExceptionDetails
      Parameters:
      code - é um Integer representando o código do term correspondente à exceção a ser buscada.
      Returns:
      Retorna o detalhe da exceção correspondente ao código.
      Throws:
      DetailsFailureException - se nenhum detalhe de exceção correspondente for encontrado.