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
1 change: 1 addition & 0 deletions chargebee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
PaymentError,
InvalidRequestError,
OperationFailedError,
UbbBatchIngestionInvalidRequestError,
)
from chargebee.filters import Filters
from chargebee.main import Chargebee
Expand Down
8 changes: 8 additions & 0 deletions chargebee/api_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class APIError(Exception):

def __init__(self, http_code, json_obj, headers=None):
Exception.__init__(self, json_obj.get("message"))
self.json_obj = json_obj
Expand Down Expand Up @@ -27,3 +28,10 @@ def __init__(self, http_code, json_obj, headers=None):
class OperationFailedError(APIError):
def __init__(self, http_code, json_obj, headers=None):
APIError.__init__(self, http_code, json_obj, headers)


class UbbBatchIngestionInvalidRequestError(APIError):
def __init__(self, http_code, json_obj, headers=None):
APIError.__init__(self, http_code, json_obj, headers)
self.batch_id = json_obj.get("batch_id")
self.failed_events = json_obj.get("failed_events")
5 changes: 5 additions & 0 deletions chargebee/http_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PaymentError,
InvalidRequestError,
OperationFailedError,
UbbBatchIngestionInvalidRequestError,
)
from chargebee import compat, util, environment
from chargebee.main import Chargebee
Expand Down Expand Up @@ -365,5 +366,9 @@ def handle_api_resp_error(url, http_code, resp_json, response_headers=None):
raise OperationFailedError(http_code, resp_json, response_headers)
elif "invalid_request" == resp_json.get("type"):
raise InvalidRequestError(http_code, resp_json, response_headers)
elif "ubb_batch_ingestion_invalid_request" == resp_json.get("type"):
raise UbbBatchIngestionInvalidRequestError(
http_code, resp_json, response_headers
)
else:
raise APIError(http_code, resp_json, response_headers)
2 changes: 1 addition & 1 deletion chargebee/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def send(
params = {}

ser_params = (
json.dumps(params)
params
if isJsonRequest
else util.serialize(params, None, None, jsonKeys)
)
Expand Down