|
1 | 1 | package io.pinecone.exceptions;
|
2 | 2 |
|
| 3 | +import org.openapitools.client.ApiException; |
| 4 | + |
3 | 5 | public class HttpErrorMapper {
|
4 | 6 |
|
5 |
| - public static void mapHttpStatusError(FailedRequestInfo failedRequestInfo) throws PineconeException { |
| 7 | + public static void mapHttpStatusError(FailedRequestInfo failedRequestInfo, |
| 8 | + ApiException apiException) throws PineconeException { |
6 | 9 | int statusCode = failedRequestInfo.getStatus();
|
7 | 10 | switch (statusCode) {
|
8 | 11 | case 400:
|
9 |
| - throw new PineconeBadRequestException(failedRequestInfo.getMessage()); |
| 12 | + throw new PineconeBadRequestException(failedRequestInfo.getMessage(), apiException); |
10 | 13 | case 401:
|
11 |
| - throw new PineconeAuthorizationException(failedRequestInfo.getMessage()); |
| 14 | + throw new PineconeAuthorizationException(failedRequestInfo.getMessage(), apiException); |
12 | 15 | case 403:
|
13 |
| - throw new PineconeForbiddenException(failedRequestInfo.getMessage()); |
| 16 | + throw new PineconeForbiddenException(failedRequestInfo.getMessage(), apiException); |
14 | 17 | case 404:
|
15 |
| - throw new PineconeNotFoundException(failedRequestInfo.getMessage()); |
| 18 | + throw new PineconeNotFoundException(failedRequestInfo.getMessage(), apiException); |
16 | 19 | case 409:
|
17 |
| - throw new PineconeAlreadyExistsException(failedRequestInfo.getMessage()); |
| 20 | + throw new PineconeAlreadyExistsException(failedRequestInfo.getMessage(), apiException); |
18 | 21 | case 500:
|
19 |
| - throw new PineconeInternalServerException(failedRequestInfo.getMessage()); |
| 22 | + throw new PineconeInternalServerException(failedRequestInfo.getMessage(), apiException); |
20 | 23 | default:
|
21 |
| - throw new PineconeUnmappedHttpException(failedRequestInfo.getMessage()); |
| 24 | + throw new PineconeUnmappedHttpException(failedRequestInfo.getMessage(), apiException); |
22 | 25 | }
|
23 | 26 | }
|
24 | 27 | }
|
0 commit comments