Esempio n. 1
0
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}
Esempio n. 2
0
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}
Esempio n. 3
0
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}
Esempio n. 4
0
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}
Esempio n. 5
0
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}
Esempio n. 6
0
    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
Esempio n. 7
0
    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
Esempio n. 8
0
    def test_sets_response_status_500(self, pyramid_request):
        handle_exception(pyramid_request, Mock())

        assert pyramid_request.response.status_int == 500
Esempio n. 9
0
def error(request):
    """Handle a request for which the handler threw an exception."""
    handle_exception(request)
    return {}
Esempio n. 10
0
    def test_triggers_sentry_capture(self, pyramid_request):
        handle_exception(pyramid_request)

        pyramid_request.sentry.captureException.assert_called_once_with()
Esempio n. 11
0
    def test_triggers_sentry_capture(self, pyramid_request):
        handle_exception(pyramid_request)

        pyramid_request.sentry.captureException.assert_called_once_with()
Esempio n. 12
0
    def test_sets_response_status_500(self, pyramid_request):
        handle_exception(pyramid_request)

        assert pyramid_request.response.status_int == 500
Esempio n. 13
0
def error(context, request):
    """Handle a request for which the handler threw an exception."""
    handle_exception(request, exception=context)
    return {}
Esempio n. 14
0
 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))