示例#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}
示例#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}
示例#3
0
文件: errors.py 项目: hypothesis/h
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}
示例#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}
示例#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}
示例#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
示例#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
示例#8
0
文件: view_test.py 项目: zhujinlong/h
    def test_sets_response_status_500(self, pyramid_request):
        handle_exception(pyramid_request, Mock())

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

        pyramid_request.sentry.captureException.assert_called_once_with()
示例#11
0
    def test_triggers_sentry_capture(self, pyramid_request):
        handle_exception(pyramid_request)

        pyramid_request.sentry.captureException.assert_called_once_with()
示例#12
0
    def test_sets_response_status_500(self, pyramid_request):
        handle_exception(pyramid_request)

        assert pyramid_request.response.status_int == 500
示例#13
0
文件: errors.py 项目: hypothesis/h
def error(context, request):
    """Handle a request for which the handler threw an exception."""
    handle_exception(request, exception=context)
    return {}
示例#14
0
文件: view_test.py 项目: magnuslim/h
 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))