{"ok": true, "next": null, "rows": [{"id": "plugin_hooks:plugin-hook-handle-exception", "page": "plugin_hooks", "ref": "plugin-hook-handle-exception", "title": "handle_exception(datasette, request, exception)", "content": "datasette  -  Datasette class \n                     \n                         You can use this to access plugin configuration options via  datasette.plugin_config(your_plugin_name) , or to render templates or execute SQL queries. \n                     \n                 \n                 \n                     request  -  Request object \n                     \n                         The current HTTP request. \n                     \n                 \n                 \n                     exception  -  Exception \n                     \n                         The exception that was raised. \n                     \n                 \n             \n             This hook is called any time an unexpected exception is raised. You can use it to record the exception. \n             If your handler returns a  Response  object it will be returned to the client in place of the default Datasette error page. \n             The handler can return a response directly, or it can return return an awaitable function that returns a response. \n             This example logs an error to  Sentry  and then renders a custom error page: \n             from datasette import hookimpl, Response\nimport sentry_sdk\n\n\n@hookimpl\ndef handle_exception(datasette, exception):\n    sentry_sdk.capture_exception(exception)\n\n    async def inner():\n        return Response.html(\n            await datasette.render_template(\n                \"custom_error.html\", request=request\n            )\n        )\n\n    return inner \n             Example:  datasette-sentry", "breadcrumbs": "[\"Plugin hooks\"]", "references": "[{\"href\": \"https://sentry.io/\", \"label\": \"Sentry\"}, {\"href\": \"https://datasette.io/plugins/datasette-sentry\", \"label\": \"datasette-sentry\"}]"}], "truncated": false}