Add exception_handler_hook optional arg #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code change adds a new feature: a custom exception handler hook that, when provided, is executed to handle error responses from Kraken. This code change is fully backward compatible.
Current scenario
All error responses from Kraken are re-tried. But in some cases, re-trying does not make sense, fi. when the transaction id does not exist.
An actual example: querying order info for a non-existing transaction id, results in many attempts, as the code fails at recognizing the error message received from Kraken:
Results in:
Scenario with this code change
Whit this PR instead I can optionally define a custom exception handler hook.
And this hook can recognize an error response from Kraken and raise, avoiding the unnecessary attempts and instead raising a proper exception.
Example code (code that uses
pykrakenapi
as requirement):Finally, this code change is backward compatible, so the existing users of this library do NOT have to change their code (unless they want to use this new feature indeed 😉 ).