Skip to content

Commit 9d1737f

Browse files
authored
Add missing raise_for_status() error handling on AS4 submission (#18)
* Add missing raise_for_status() error handling on AS4 submission * Improve error handling for non-XML error responses
1 parent ff385f2 commit 9d1737f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/peppol_py/as4_sender.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ def post_edelivery_as4_document(endpoint_url, body, headers, timeout):
3838
try:
3939
response_xml = etree.fromstring(r.content)
4040
except (etree.XMLSyntaxError, ValueError) as e:
41+
if r.status_code >= 400:
42+
raise make_sendpeppol_error(
43+
"Endpoint error",
44+
'server-error',
45+
temporary=True,
46+
url=endpoint_url,
47+
endpoint={
48+
'status_code': r.status_code,
49+
'error_xml': None,
50+
'error_msg': r.content,
51+
}
52+
)
4153
raise make_sendpeppol_error(str(e), 'server-error', temporary=True, url=endpoint_url)
4254

4355
if not r.status_code == 200 or response_xml.find('.//{*}Header//{*}Receipt') is None:

0 commit comments

Comments
 (0)