def json_error(request): """Handle an unexpected exception where the request asked for JSON.""" handle_exception(request) message = _("Hypothesis had a problem while handling this request. " "Our team has been notified. Please contact [email protected]" " if the problem persists.") return {'status': 'failure', 'reason': message}
def json_error(context, request): """Handle an unexpected exception in an API view.""" handle_exception(request, exception=context) message = _( "Hypothesis had a problem while handling this request. " "Our team has been notified. Please contact [email protected]" " if the problem persists.") return {"status": "failure", "reason": message}
def json_error(context, request): """Handle an unexpected exception where the request asked for JSON.""" handle_exception(request, exception=context) message = _( "Hypothesis had a problem while handling this request. " "Our team has been notified. Please contact [email protected]" " if the problem persists." ) return {"status": "failure", "reason": message}
def json_error(request): """Handle an unexpected exception where the request asked for JSON.""" handle_exception(request) message = _("Uh-oh, something went wrong! We're very sorry, our " "application wasn't able to load this page. The team has " "been notified and we'll fix it shortly. If the problem " "persists or you'd like more information please email " "[email protected] with the subject 'Internal Server " "Error'.") return {'status': 'failure', 'reason': message}
def test_reraises_in_debug_mode(self, pyramid_request): pyramid_request.debug = True dummy_exc = ValueError('dummy') try: raise dummy_exc except: with pytest.raises(ValueError) as exc: handle_exception(pyramid_request) assert exc.value == dummy_exc
def test_sets_response_status_500(self, pyramid_request): handle_exception(pyramid_request, Mock()) assert pyramid_request.response.status_int == 500
def error(request): """Handle a request for which the handler threw an exception.""" handle_exception(request) return {}
def test_triggers_sentry_capture(self, pyramid_request): handle_exception(pyramid_request) pyramid_request.sentry.captureException.assert_called_once_with()
def test_sets_response_status_500(self, pyramid_request): handle_exception(pyramid_request) assert pyramid_request.response.status_int == 500
def error(context, request): """Handle a request for which the handler threw an exception.""" handle_exception(request, exception=context) return {}
def test_triggers_sentry_capture_with_old_exception( self, pyramid_request, old_exception): handle_exception(pyramid_request, old_exception) traceback = getattr(old_exception, "__traceback__", None) pyramid_request.sentry.captureException.assert_called_once_with( (type(old_exception), old_exception, traceback))