Skip to content
Merged
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
8 changes: 5 additions & 3 deletions marklogic/transactions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from requests import Response, Session
from requests.exceptions import HTTPError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -71,9 +72,10 @@ def __exit__(self, *args):
if len(args) > 1 and isinstance(args[1], Exception)
else self.commit()
)
assert (
204 == response.status_code
), f"Could not end transaction; cause: {response.text}"
# raise_for_status() is not used here as it results in an error without any
# context of what went wrong.
if response.status_code != 204:
raise HTTPError(f"Could not end transaction; cause: {response.text}")


class TransactionManager:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
from marklogic import Client
from marklogic.documents import Document
from requests.exceptions import HTTPError

PERMS = {"python-tester": ["read", "update"]}

Expand Down Expand Up @@ -65,7 +66,7 @@ def test_time_limit(client: Client):
doc1 = Document("/t1.json", {}, permissions=PERMS)
client.documents.write(doc1, tx=tx)

except AssertionError as error:
except HTTPError as error:
assert error.args[0].startswith("Could not end transaction")
assert "No transaction with identifier" in error.args[0]
assert "XDMP-NOTXN" in error.args[0]
Expand Down