Typer
Learn how to use Sentry to capture Typer exceptions.
The TyperIntegration
captures exceptions raised when using Typer CLI applications.
Install Typer and the Sentry Python SDK.
Copied
pip install --upgrade "sentry-sdk" typer
To enable the TyperIntegration
, add it to the integrations
list of your sentry_sdk.init
.
Copied
import sentry_sdk
from sentry_sdk.integrations.typer import TyperIntegration
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
integrations=[TyperIntegration()],
)
Create a small CLI application:
Copied
import typer
import sentry_sdk
from sentry_sdk.integrations.typer import TyperIntegration
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
integrations=[TyperIntegration()],
)
def main():
1 / 0
if __name__ == "__main__":
typer.run(main)
When you run this, Sentry will capture the ZeroDivisionError
from the main()
function and you'll be able to see it on sentry.io.
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").