Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2011 chargebee.com
* All Rights Reserved.
*/

package com.chargebee.exceptions;

import com.chargebee.APIException;
import org.json.*;
import java.util.List;
import java.util.Map;


public class UbbBatchIngestionInvalidRequestException extends APIException{
public final String batchId;
public final JSONArray failedEvents;
public UbbBatchIngestionInvalidRequestException(int httpStatusCode, String message, JSONObject jsonObj, Map<String, List<String>> headers) {
super(httpStatusCode, message, jsonObj);
this.batchId=jsonObj.optString("batch_id");
this.failedEvents=jsonObj.optJSONArray("failed_events");
}
}
6 changes: 5 additions & 1 deletion src/main/java/com/chargebee/internal/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private static void logRetry(int attempt, int statusCode, int delayMs, boolean e

private static Resp sendRequest(HttpURLConnection conn) throws IOException {
int httpRespCode = conn.getResponseCode();
final String UBB_BATCH_INGESTION_INVALID_REQUEST = "ubb_batch_ingestion_invalid_request";
Map<String, List<String>> responseHeaders = conn.getHeaderFields();
if (httpRespCode == HttpURLConnection.HTTP_NO_CONTENT) {
throw new RuntimeException("Got http_no_content response");
Expand All @@ -225,7 +226,10 @@ private static Resp sendRequest(HttpURLConnection conn) throws IOException {
jsonResp.getString("api_error_code");
String type = jsonResp.optString("type");
String exceptionMessage = jsonResp.getString("message");
if (isBatchApi(conn)) {
if (UBB_BATCH_INGESTION_INVALID_REQUEST.equals(type)) {
throw new UbbBatchIngestionInvalidRequestException(httpRespCode, exceptionMessage, jsonResp, responseHeaders);
}
else if (isBatchApi(conn)) {
throw new BatchAPIException(httpRespCode, exceptionMessage, jsonResp, responseHeaders);
} else if ("payment".equals(type)) {
throw new PaymentException(httpRespCode, exceptionMessage, jsonResp, responseHeaders);
Expand Down