Add exception_handler_hook optional arg#58
Add exception_handler_hook optional arg#58puntonim wants to merge 1 commit intodominiktraxl:masterfrom
Conversation
|
@dominiktraxl Hi, any chance to take a look at this? 😝 |
|
Hi @puntonim, thank you for the contribution. Looks like a useful feature, and I'm fine with the implementation as well. I just have one request: could you please expand a little on the example in the docstring? The example as it is now prints the error, which is already done when an exception is caught. Maybe you could use the example you describe here, as this is a practical use case. |
Good point, I'll work on that! |
|
@puntonim are you planning on updating this? I'm getting a similar issue so would be great if you could update this? In my scenario, I'm getting locked into the following loop since the error is not being handled: For me, I'd be good with just printing the error and returning it. |
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
pykrakenapias 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 😉 ).