org.labkey.remoteapi

## Class CommandException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - org.labkey.remoteapi.CommandException

- All Implemented Interfaces:
    java.io.Serializable
  Direct Known Subclasses:
    ApiVersionException

      public class CommandException
      extends java.lang.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:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommandException(java.lang.String message)` Constructs a new CommandException given a message only.
    `CommandException(java.lang.String message, int statusCode, java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String responseText)` Constructs a new CommandException given a message, HTTP status code, and exception property map (which may be null).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Map<java.lang.String,java.lang.Object>` | `getProperties()` Returns the exception property map, or null if no map was set.
    `java.lang.String` | `getResponseText()` Returns the text of the response
    `int` | `getStatusCode()` Returns the HTTP status code returned by the server.

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CommandException

          public CommandException(java.lang.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(java.lang.String message,
                                  int statusCode,
                                  java.util.Map<java.lang.String,java.lang.Object> properties,
                                  java.lang.String responseText)

      Constructs a new CommandException given a message, HTTP status code, and exception property map (which may be null).
      Parameters:
        `message` - The message text (should not be null).
        `statusCode` - The HTTP status code.
        `properties` - The exception property map (may be null)
        `responseText` - The full response text (may be null)

  - ### Method Detail

    - #### getStatusCode

          public int getStatusCode()

      Returns the HTTP status code returned by the server.
      Returns:
        The HTTP status code.

    - #### getResponseText

          public java.lang.String getResponseText()

      Returns the text of the response
      Returns:
        The text of the response

    - #### getProperties

          public java.util.Map<java.lang.String,java.lang.Object> getProperties()

      Returns the exception property map, or null if no map was set.
      Returns:
        The exception property map or null.