Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupling error handling for Document Creation #149

Closed
Closed
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
9 changes: 7 additions & 2 deletions authorizenet/apicontrollersbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,18 @@ def execute(self):
self._httpResponse = self._httpResponse.text[3:] #strip BOM
self.afterexecute()
try:
self._response = apicontractsv1.CreateFromDocument(self._httpResponse)
self._response = apicontractsv1.CreateFromDocument(self._httpResponse)
except (pyxb.exceptions_.PyXBException, pyxb.exceptions_.PyXBError) as e:
error_details = e.details()
raise e(
'Validation Error Creating Document: At %s, with Arguments: %s, details:',
type(e), e.args, str(error_details))
try:
#objectify code
xmlResponse= self._response.toxml(encoding=constants.xml_encoding, element_name=self.getrequesttype())
xmlResponse = xmlResponse.replace(constants.nsNamespace1, b'')
xmlResponse = xmlResponse.replace(constants.nsNamespace2, b'')
self._mainObject = objectify.fromstring(xmlResponse)

except Exception as objectifyexception:
anetLogger.error( 'Create Document Exception: %s, %s', type(objectifyexception), objectifyexception.args )
responseString = self._httpResponse
Expand Down
9 changes: 8 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[metadata]
description-file = DESCRIPTION.rst
description-file = DESCRIPTION.rst
[flake8]
max-line-length = 120
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules

[pycodestyle]
max-line-length = 120
exclude=.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules