Skip to content

Commit c3e9b6c

Browse files
committed
Decoupling error handling for Document Creation Fixes AuthorizeNet#148
1 parent 11f5f69 commit c3e9b6c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Diff for: authorizenet/apicontrollersbase.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,18 @@ def execute(self):
143143
self._httpResponse = self._httpResponse.text[3:] #strip BOM
144144
self.afterexecute()
145145
try:
146-
self._response = apicontractsv1.CreateFromDocument(self._httpResponse)
146+
self._response = apicontractsv1.CreateFromDocument(self._httpResponse)
147+
except (pyxb.exceptions_.PyXBException, pyxb.exceptions_.PyXBError) as e:
148+
error_details = e.details()
149+
raise e(
150+
'Validation Error Creating Document: At %s, with Arguments: %s, details:',
151+
type(e), e.args, str(error_details))
152+
try:
147153
#objectify code
148154
xmlResponse= self._response.toxml(encoding=constants.xml_encoding, element_name=self.getrequesttype())
149155
xmlResponse = xmlResponse.replace(constants.nsNamespace1, b'')
150156
xmlResponse = xmlResponse.replace(constants.nsNamespace2, b'')
151157
self._mainObject = objectify.fromstring(xmlResponse)
152-
153158
except Exception as objectifyexception:
154159
anetLogger.error( 'Create Document Exception: %s, %s', type(objectifyexception), objectifyexception.args )
155160
responseString = self._httpResponse

Diff for: setup.cfg

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
[metadata]
2-
description-file = DESCRIPTION.rst
2+
description-file = DESCRIPTION.rst
3+
[flake8]
4+
max-line-length = 120
5+
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules
6+
7+
[pycodestyle]
8+
max-line-length = 120
9+
exclude=.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules

0 commit comments

Comments
 (0)