Class CommandException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.labkey.remoteapi.CommandException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ApiVersionException

public class CommandException extends Exception
Represents an exception that occurs while executing a command.

An instance of this class is typically thrown when the server returns a non-success HTTP status code (>= 400). The developer may catch this exception type and use the getStatusCode() method to retrieve the particular HTTP status code.

If the server generated an exception and sent details back to the client, the exception message will be set as the message text, which is returned from the toString() method. Other properties about the exception, such as the exception class and stack trace, may be obtained via the getProperties() method.

See Also:
  • Constructor Details

    • CommandException

      public CommandException(String message)
      Constructs a new CommandException given a message only. The status code and properties map will be set to 0 and null respectively
      Parameters:
      message - The message text (should not be null).
    • CommandException

      public CommandException(String message, int statusCode, org.json.JSONObject jsonProperties, String responseText, String contentType, String authHeaderValue)
      Constructs a new CommandException given a message, HTTP status code, exception property map, responseText, and contentType.
      Parameters:
      message - The message text (should not be null).
      statusCode - The HTTP status code.
      jsonProperties - The exception property JSONObject (may be null)
      responseText - The full response text (may be null)
      contentType - The response content type (may be null)
      authHeaderValue - The value of the WWW-Authenticate header (may be null)
  • Method Details

    • getContentType

      public String getContentType()
    • getStatusCode

      public int getStatusCode()
      Returns the HTTP status code returned by the server.
      Returns:
      The HTTP status code.
    • getResponseText

      public String getResponseText()
      Returns the text of the response
      Returns:
      The text of the response
    • getAuthHeaderValue

      public String getAuthHeaderValue()
      Returns the value of the WWW-Authenticate header
      Returns:
      The value or null
    • getProperties

      public Map<String,Object> getProperties()
      Returns the exception property map, or null if no map was set.
      Returns:
      The exception property map or null.