Class WellComposedErrorBody


  • public class WellComposedErrorBody
    extends Object
    Object acting as a payload for the ResponseErrorObject.
    Author:
    tesarst
    • Constructor Detail

      • WellComposedErrorBody

        public WellComposedErrorBody​(javax.ws.rs.core.Response.Status status,
                                     String message)
        Creates a new well composed error body that can be used as a payload for a GemmaApiException, or ResponseErrorObject.
        Parameters:
        status - the response status that caused this error.
        message - the message to be displayed as the main cause of the error.
    • Method Detail

      • addExceptionFields

        public static void addExceptionFields​(WellComposedErrorBody body,
                                              Throwable t)
        Adds descriptive values from the throwable object to the instance of WellComposedErrorBody.
        Parameters:
        body - the object to add the throwable description to.
        t - the throwable to read the description from.
      • addErrorsField

        public void addErrorsField​(String key,
                                   String value)
        Adds a new field into the errors array property.
        Parameters:
        key - key in the array where the value will be inserted.
        value - value of the error that will be inserted.
      • getStatus

        public javax.ws.rs.core.Response.Status getStatus()
        Returns:
        the Response Status of this error body.
      • getCode

        public int getCode()
        Used by JSON Serializer.
        Returns:
        the code of the Response Status of this error body.
      • getMessage

        public String getMessage()
        Used by JSON Serializer.
        Returns:
        the message of this error body.
      • getErrors

        public Map<String,​String> getErrors()
        Used by JSON Serializer.
        Returns:
        the errors array of this error body.