Skip to content

Commit

Permalink
Merge pull request #659 from ianco/master
Browse files Browse the repository at this point in the history
Check for fatal ledger errors on dispatch task completion
  • Loading branch information
swcurran authored Aug 14, 2020
2 parents 7204c00 + f5077f3 commit dc1cee7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ def dispatch_complete(self, message: InboundMessage, completed: CompletedTask):
LOGGER.exception(
"Exception in message handler:", exc_info=completed.exc_info
)
if isinstance(completed.exc_info[1], LedgerConfigError) or isinstance(
completed.exc_info[1], LedgerTransactionError
):
LOGGER.error("Shutdown with %s", str(completed.exc_info[1]))
self.admin_server.notify_fatal_error()
else:
LOGGER.error("DON'T Shutdown with %s", str(completed.exc_info[1]))
self.inbound_transport_manager.dispatch_complete(message, completed)

async def get_stats(self) -> dict:
Expand Down
21 changes: 21 additions & 0 deletions aries_cloudagent/core/tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,24 @@ async def test_webhook_router(self):
mock_enqueue.assert_called_once_with(
test_topic, test_payload, test_endpoint, test_attempts
)

async def test_dispatch_complete_fatal_x(self):
builder: ContextBuilder = StubContextBuilder(self.test_settings)
conductor = test_module.Conductor(builder)

message_body = "{}"
receipt = MessageReceipt(direct_response_mode="snail mail")
message = InboundMessage(message_body, receipt)
mock_task = async_mock.MagicMock(
exc_info=(test_module.LedgerTransactionError, ("Ledger is wobbly"), "..."),
ident="abc",
timing={
"queued": 1234567890,
"unqueued": 1234567899,
"started": 1234567901,
"ended": 1234567999,
},
)

await conductor.setup()
conductor.dispatch_complete(message, mock_task)

0 comments on commit dc1cee7

Please sign in to comment.