Solution
from sentry_sdk import capture_exception
@app.errorhandler(Exception)
def internal_server_error(error):
capture_exception(error)
template_name, context = ErrorPages().error500(error)
return (render_template(template_name, **context), 500)