Package ai.webscraping.exception
Class ApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
ai.webscraping.exception.WebScrapingAIException
ai.webscraping.exception.ApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AuthenticationException,BadRequestException,GatewayTimeoutException,PaymentRequiredException,RateLimitException,ServerException
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ApiExceptionforStatus(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.getBody()bodyfield from the error envelope (target-page error body), ornull.intRaw HTTP response body.Application-level status code from the API error envelope, ornull.Application-level status message from the API error envelope, ornull.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ApiException
-
-
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
Application-level status code from the API error envelope, ornull. -
getStatusMessage
Application-level status message from the API error envelope, ornull. -
getBody
bodyfield from the error envelope (target-page error body), ornull. -
getResponseBody
Raw HTTP response body.
-