Class ApiException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AuthenticationException, BadRequestException, GatewayTimeoutException, PaymentRequiredException, RateLimitException, ServerException

public class ApiException extends WebScrapingAIException
Thrown when the API returns a non-2xx HTTP response. Carries the HTTP status plus the API's documented error envelope (message, status_code, status_message, body). The last three are populated when the API surfaces a target-page error as a 5xx. Catch this to handle any HTTP response error; catch a per-status subclass (BadRequestException, RateLimitException, etc.) to handle a specific status code.
See Also:
  • Constructor Details

  • Method Details

    • forStatus

      public static ApiException forStatus(int httpStatus, String message, Integer statusCode, String statusMessage, String body, String responseBody)
      Maps an HTTP status to the matching per-status subclass; falls back to ApiException.
    • getHttpStatus

      public int getHttpStatus()
    • getStatusCode

      public Integer getStatusCode()
      Application-level status code from the API error envelope, or null.
    • getStatusMessage

      public String getStatusMessage()
      Application-level status message from the API error envelope, or null.
    • getBody

      public String getBody()
      body field from the error envelope (target-page error body), or null.
    • getResponseBody

      public String getResponseBody()
      Raw HTTP response body.