Closed chr0x6eos closed 3 years ago
Hi, can you please give a short example. I'll look over it and if needed, work on a fix. There might also be a workaround depending on your use case: Have you tried catching the exception, that is being raised in the callback function, in the callback function itself?
Yes, after catching the exception the program prints the error message and does not move further in the code.
That is supposed to happen, since you should code what should happen next or if there was some mistake with recognizing the card then the card should be taken off the reader and put on it again.
If you want to see a full example implementation for raising exceptions in the callback you can look at my Praesidium demo under the function card_connect
(line 251).
The following wasn't tested so it probably doesn't work. It was just written quickly to give an overview of how it should work:
def some_function_that_does_something():
* Do something *
try:
* Do something that can raise an exception *
except Exception as details:
print('Your error: ' + details)
* Continue doing something *
def connect():
try:
* connect to card code *
some_function_that_does_something()
except Exception as details:
print('Error while connecting to card: ' + details)
finally:
* Optional: Do some cleanup*
If you raise an exception in some_function_that_does_something()
outside of the try:
then that exception will land in the connect()
function and I don't think you want that.
The exception in connect()
should be used to indicate mistakes with the card since you want the program to not continue if for example a wrong card is put on the reader (because any card on the reader can trigger the callback, its your job to check if its a Blockchain Security 2Go card).
I hope i was able to clarify some things...
issue seems to be solved - closing
When an exception in the callback function connect(self)/disconnect(self) occurrs, the callback function never leaves and the program is stuck.