Example #1
0
 def _notify_resource_events_after(success, request):
     """Notify the accumulated resource events if transaction succeeds.
     """
     if success:
         for event in request.get_resource_events(after_commit=True):
             try:
                 request.registry.notify(event)
             except Exception:
                 logger.error("Unable to notify", exc_info=True)
Example #2
0
 def _notify_resource_events_after(success, request):
     """Notify the accumulated resource events if transaction succeeds.
     """
     if success:
         for event in request.get_resource_events(after_commit=True):
             try:
                 request.registry.notify(event)
             except Exception:
                 logger.error("Unable to notify", exc_info=True)
Example #3
0
def error(context, request):
    """Catch server errors and trace them."""
    if isinstance(context, httpexceptions.Response):
        return reapply_cors(request, context)

    if isinstance(context, storage_exceptions.BackendError):
        logger.critical(context.original, exc_info=True)
        response = httpexceptions.HTTPServiceUnavailable()
        return service_unavailable(response, request)

    logger.error(context, exc_info=True)

    error_msg = "A programmatic error occured, developers have been informed."
    info = request.registry.settings['error_info_link']
    response = http_error(httpexceptions.HTTPInternalServerError(),
                          message=error_msg,
                          info=info)

    return reapply_cors(request, response)
Example #4
0
def error(context, request):
    """Catch server errors and trace them."""
    if isinstance(context, httpexceptions.Response):
        return reapply_cors(request, context)

    if isinstance(context, storage_exceptions.BackendError):
        logger.critical(context.original, exc_info=True)
        response = httpexceptions.HTTPServiceUnavailable()
        return service_unavailable(response, request)

    logger.error(context, exc_info=True)

    error_msg = "A programmatic error occured, developers have been informed."
    info = request.registry.settings['error_info_link']
    response = http_error(httpexceptions.HTTPInternalServerError(),
                          message=error_msg,
                          info=info)

    return reapply_cors(request, response)