Skip to content

Commit 59e1117

Browse files
committed
http error exception
1 parent b4c161c commit 59e1117

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

maxipago/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ class CardException(MaxipagoException):
2929

3030
class PaymentException(MaxipagoException):
3131
pass
32+
33+
34+
#http
35+
class HttpErrorException(MaxipagoException):
36+
pass

maxipago/managers/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# coding: utf-8
22
import requests
3+
from maxipago.exceptions import HttpErrorException
34
from maxipago.utils import etree, create_element_recursively
45

56

@@ -24,6 +25,8 @@ def __init__(self, maxid, api_key, api_version, sandbox):
2425
def request(self, xml_data, api_type=None):
2526
uri = self.get_uri(api_type)
2627
response = requests.post(url=uri, data=xml_data, headers={'content-type': 'text/xml'})
28+
if not str(response.status_code).startswith('2'):
29+
raise HttpErrorException(u'Error %s: %s' % (response.status_code, response.reason))
2730
return response
2831

2932
def get_uri(self, api_type=None):

0 commit comments

Comments
 (0)