Class ResponseMessage

java.lang.Object
org.chenile.base.response.ResponseMessage

public class ResponseMessage extends Object
A detailed response message that contains a bunch of information.
  • Code - HTTP Status code
  • subErrorCode - The specific error returned by the service. Typically, there must be an enum that the service defines which has all the possible values for the subErrorCode that the particular service returns. Sub error codes are mapped to an i18n message that can have substitutable parameters.
  • Description - of the error. Must be internationalized and must be found in a message bundle
  • Field - at which the error occurred. This is useful if there is a validation failure for a particular field
  • Severity - which can have the value WARN or ERROR
  • Params - which contain replacements for the substitutable parameters contained in the i18n message
    • Field Details

      • field

        private String field
      • description

        private String description
        A message. Can be a translated message after applying i18n
      • code

        private HttpStatus code
        The HTTP Status Code - default to internal server error
      • subErrorCode

        private int subErrorCode
        The error code specific to the service
      • params

        private Object[] params
        Params that might be needed to render the description. These contain substitutable parameters Ex: Resource {0} not found
      • severity

        private ErrorType severity
    • Constructor Details

      • ResponseMessage

        public ResponseMessage()
    • Method Details

      • getDescription

        public String getDescription()
      • setDescription

        public void setDescription(String message)
      • getCode

        public int getCode()
      • setCode

        public void setCode(int code)
      • setCode

        public void setCode(HttpStatus code)
      • getParams

        public Object[] getParams()
      • setParams

        public void setParams(Object[] params)
      • getSeverity

        public ErrorType getSeverity()
      • setSeverity

        public void setSeverity(ErrorType severity)
      • toString

        public String toString()
        Overrides:
        toString in class Object
      • getField

        public String getField()
      • setField

        public void setField(String field)
      • getSubErrorCode

        public int getSubErrorCode()
      • setSubErrorCode

        public void setSubErrorCode(int subErrorCode)
      • clone

        public ResponseMessage clone()
        Overrides:
        clone in class Object