Package com.ngrok.definitions

# Class NgrokApiError

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.ngrok.definitions.NgrokApiError

All Implemented Interfaces:
  `Serializable`

public class NgrokApiError extends RuntimeException
Representation of an API error from ngrok.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NgrokApiError(int httpStatusCode)`
  Creates a new API error.
  `NgrokApiError(int httpStatusCode, Optional<String> responseBody, Throwable cause)`
  Creates a new API error.
  `NgrokApiError(String message, int httpStatusCode, Optional<String> errorCode, Map<String,String> details)`
  Creates a new API error.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map<String,String>`
  `getDetails()`
  Fetches any further details about the error.
  `Optional<String>`
  `getErrorCode()`
  Fetches the ngrok API error code, if any.
  `int`
  `getHttpStatusCode()`
  Fetches the HTTP status code.
  `boolean`
  `isErrorCode(String... codes)`
  Checks if this error object contains one of the provided codes.

  ### 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 Details

  - ### NgrokApiError

    public NgrokApiError(String message, int httpStatusCode, Optional<String> errorCode, Map<String,String> details)
    Creates a new API error.
    Parameters:
      `message` - informative message
      `httpStatusCode` - HTTP response status
      `errorCode` - ngrok API error code
      `details` - arbitrary error details

  - ### NgrokApiError

    public NgrokApiError(int httpStatusCode, Optional<String> responseBody, Throwable cause)
    Creates a new API error.
    Parameters:
      `httpStatusCode` - HTTP response status
      `responseBody` - possible response body
      `cause` - exception cause

  - ### NgrokApiError

    public NgrokApiError(int httpStatusCode)
    Creates a new API error.
    Parameters:
      `httpStatusCode` - HTTP response status

- ## Method Details

  - ### getHttpStatusCode

    public int getHttpStatusCode()
    Fetches the HTTP status code.
    Returns:
      HTTP response status

  - ### getErrorCode

    public Optional<String> getErrorCode()
    Fetches the ngrok API error code, if any.
    Returns:
      ngrok API error code

  - ### getDetails

    public Map<String,String> getDetails()
    Fetches any further details about the error.
    Returns:
      key-value map containing error details

  - ### isErrorCode

    public boolean isErrorCode(String... codes)
    Checks if this error object contains one of the provided codes.
    Parameters:
      `codes` - error codes to check
    Returns:
      whether or not one of the codes matches what is in this error object