-
Notifications
You must be signed in to change notification settings - Fork 125
Include reason for BadApiResponse
in PromoteTransactionCommand
#311
Comments
The response payload should already be included in the |
@todofixthis I'm talking about this exception: iota.py/iota/commands/extended/promote_transaction.py Lines 38 to 43 in 9416068
The response from the node should be alright from the adapter's perspective, it it should contain status , info and duration fields.
Btw a question: how are exceptions raised with |
Including the information in the exception message is often convenient, but sometimes not (e.g., the context for an exception might be a bundle, and that means a VERY long exception message!). Attaching additional information to the exception requires a bit of extra effort on the application developer's part, but it opens up additional options for troubleshooting. E.g.,: try:
pt_response = api.promote_transaction(...)
except BadApiResponse as e:
# Production scenario:
# Log exception details to database, log, DLQ, etc. for forensics.
log_to_database(e.message, e.context, # etc.
# Development scenario:
# Display context information with the exception, to make it easier to debug the issue.
pprint(e.context)
raise In particular, I used this technique on a previous project that logged exceptions (and their Additionally, for developers who are not familiar with PyOTA internals, this gives them a way to inspect/debug values that are relevant to the exception, in a way that doesn't require them to edit/debug 3rd-party code. |
Thanks @todofixthis for the explanation, I'm gonna include it in for #310. |
PromoteTransactionCommand
callsCheckConsistencyCommand
internally to determine if the tail transaction can be promoted or not.When
status
in CC response isFalse
,BadApiResponse
is raised which should contain theinfo
field from CC response as well. This is the reason returned by the node.The text was updated successfully, but these errors were encountered: