Package error
Class GlobalpingApiError
java.lang.Object
java.lang.Throwable
java.lang.Exception
error.GlobalpingApiError
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ForbiddenException,InternalServerErrorException,NotFoundException,ProbesNotFoundException,TooManyRequestsException,UnauthorizedException,ValidationException
Represents an API error encountered when interacting with the Globalping service. By default, it
throws like
Exception but captures statusCode as well.
The only public constructor uses raise(ByteArrayOutputStream, HttpURLConnection)
method reads the response stream, extracts the status code, and throws a specific exception based
on the HTTP response code as follows:
IOExceptionif an I/O error occurs while reading the response.ValidationExceptionif the API returns a 400 (Bad Request with Validation errors).UnauthorizedExceptionif the API returns a 401 (Unauthorized).ForbiddenExceptionif the API returns a 403 (Forbidden).NotFoundExceptionif the API returns a 404 (Not Found).ProbesNotFoundExceptionif the API returns a 422 (Unprocessable Entity).TooManyRequestsExceptionif the API returns a 429 (Too Many Requests).InternalServerErrorExceptionif the API returns a 500 (Internal Server Error).GlobalpingApiErrorif the API returns any other status code (default).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGlobalpingApiError(ByteArrayOutputStream responseStream, HttpURLConnection conn) -
Method Summary
Modifier and TypeMethodDescriptionintstatic voidraise(ByteArrayOutputStream responseStream, HttpURLConnection conn) This public method is used to trigger an exception depending on the Gloobalping service response.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
GlobalpingApiError
public GlobalpingApiError(ByteArrayOutputStream responseStream, HttpURLConnection conn) throws IOException, GlobalpingApiError - Throws:
IOExceptionGlobalpingApiError
-
-
Method Details
-
raise
public static void raise(ByteArrayOutputStream responseStream, HttpURLConnection conn) throws IOException, GlobalpingApiError This public method is used to trigger an exception depending on the Gloobalping service response.- Parameters:
responseStream-ByteArrayOutputStreamresponse from the service.conn-HttpURLConnectionunderlying HTTP connection.- Throws:
IOException- gets triggered when there is an error in underlying I/O.GlobalpingApiError- excepted and gets triggered depending on the connection response code.
-
getStatusCode
public int getStatusCode()
-