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

Support the Sanic framework #320

Open
robd003 opened this issue Jun 4, 2022 · 2 comments
Open

Support the Sanic framework #320

robd003 opened this issue Jun 4, 2022 · 2 comments
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature

Comments

@robd003
Copy link

robd003 commented Jun 4, 2022

I'd like to use BugSnag on my Sanic backends

@johnkiely1
Copy link
Member

Hi @robd003,
We have added a backlog item to consider official support for Sanic. We will let you know of updates.
However, in the meantime, we believe you can probably implement this yourself using the Sanic custom error handlers.

Something like the following should trigger an error and report it to Bugsnag. Perhaps you could modify this to your needs.

from sanic import Sanic
from sanic.response import json
from sanic.handlers import ErrorHandler
import bugsnag
​
​
bugsnag.configure(api_key='your-api-key-here')
​
app = Sanic("my-hello-world-app")
​
​
class BugsnagErrorHandler(ErrorHandler):
    def default(self, request, exception):
        bugsnag.auto_notify(exception)
        return super().default(request, exception)
​
app.error_handler = BugsnagErrorHandler()
​
​
@app.route('/')
async def will_make_an_error(request):
    raise Exception('oh no')
​
if __name__ == '__main__':
    app.run()

@johnkiely1 johnkiely1 added feature request Request for a new feature backlog We hope to fix this feature/bug in the future labels Jun 9, 2022
@robd003
Copy link
Author

robd003 commented Jun 10, 2022

Great, I'll give that a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants