Skip to content

Commit c554010

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

authorizenet/apicontrollersbase.py

Lines changed: 7 additions & 2 deletions
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

0 commit comments

Comments
 (0)