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
Representation of an API error from ngrok.
- See Also:
-
Constructor Summary
ConstructorDescriptionNgrokApiError
(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 TypeMethodDescriptionFetches any further details about the error.Fetches the ngrok API error code, if any.int
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
-
Constructor Details
-
NgrokApiError
public NgrokApiError(String message, int httpStatusCode, Optional<String> errorCode, Map<String, String> details) Creates a new API error.- Parameters:
message
- informative messagehttpStatusCode
- HTTP response statuserrorCode
- ngrok API error codedetails
- arbitrary error details
-
NgrokApiError
Creates a new API error.- Parameters:
httpStatusCode
- HTTP response statusresponseBody
- possible response bodycause
- 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
Fetches the ngrok API error code, if any.- Returns:
- ngrok API error code
-
getDetails
Fetches any further details about the error.- Returns:
- key-value map containing error details
-
isErrorCode
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
-