Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intercept Anki's exception handler #2

Open
alexbowe opened this issue Feb 19, 2023 · 3 comments
Open

Intercept Anki's exception handler #2

alexbowe opened this issue Feb 19, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@alexbowe
Copy link
Collaborator

Anki's default exception handler seems to use showInfo and strips information like the stack trace. This makes it hard to debug issues, such as #1.

We should intercept Anki's exception handler to:

  1. Show more useful information (such as the exception type, the location in code [if possible], and the whole message).
  2. Direct the user to submit a ticket on GitHub.
  3. Log the stack trace.

If SmoothBrain moves to a web API, we should probably send the log to us (conditioned on the user opting in to submit information to us to improve the program).

@alexbowe alexbowe added the enhancement New feature or request label Feb 19, 2023
@alexbowe alexbowe self-assigned this Feb 24, 2023
@alexbowe
Copy link
Collaborator Author

Intercepting exceptions causes Anki to crash if the exceptions occur in one of Anki's Op threads. So I'd either need to make it single threaded, or make my own multithreading code (which I tried before, which also crashed Anki).

Marking this as blocked for now.

@alexbowe
Copy link
Collaborator Author

Moving this out of the error handling epic for now because I can just ask users to send the log file after #8.

@alexbowe alexbowe removed their assignment Mar 13, 2023
@abdnh
Copy link
Collaborator

abdnh commented Mar 21, 2023

We can tell Anki not to intercept exceptions in CollectionOp by something like this, which will actually trigger another exception handler in Anki that shows debugging instructions and the stack trace:

def on_failure(exception: Exception) -> None:
    raise exception

CollectionOp(parent=mw, op=op).failure(on_failure).run_in_background()

We can then add specific instructions for exceptions we anticipate instead of just re-raising them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants