Errors may occur during API interactions. It's essential to capture and handle these errors appropriately. In the LastBounce API, errors are often presented as HTTP code responses. This guide will explain how to interpret and manage these error responses.
Understanding HTTP Error Responses:
-
HTTP Code Interpretation: The Intelligent Verification API returns standard HTTP response codes to indicate the status of your request. Common error codes include:
4xx
: Client errors. This group indicates that the client seems to have made an error.5xx
: Server errors. This group indicates the server failed to fulfill a valid request.
-
Sample Error Response: When the API encounters an error, it returns a structured JSON detailing the nature of the error. Here's a sample error response:
{ "httpStatus": "BAD_REQUEST", "code": 400, "timeStamp": "2022-03-01T07:05:32.204+00:00", "codeName": "BAD_REQUEST", "exceptionName": "InvalidParameterException", "message": "jobId format1 is not valid" }
Let's break down the key fields:
- httpStatus: Describes the HTTP status. For instance, "BAD_REQUEST" corresponds to HTTP 400.
- code: The numerical representation of the HTTP status. 400 means Bad Request.
- timeStamp: The time when the error occurred.
- codeName: Another representation of the HTTP status.
- exceptionName: Provides a more detailed indication of the error type.
- message: A human-readable message describing the nature of the error.
-
Error Handling Steps:
- Capture the HTTP response: Whenever you make a request, capture the response, especially when it's in the 4xx or 5xx range.
- Log the Error: Store or display the error details (
timeStamp
,exceptionName
,message
) for debugging or audit purposes. - Act Accordingly: Depending on the error (e.g.,
InvalidParameterException
), you might need to correct your request and resend it or notify relevant parties about the issue.
Comments
0 comments
Article is closed for comments.