(func)
return wrapper
Decorator that catches InputErrors and returns an error page.
Decorator that catches InputErrors and returns an error page.
Decorator that catches InputErrors and returns an error page .
def catch_error_as_http(func):
    """
    Decorator that catches InputErrors and returns an error page.
    """
    @wraps(func)
    def wrapper(*args, **kwargs):
        try:
            result = func(*args, **kwargs)
        except exps.InputError as e:
            logger.warning("An exception occurred processing request for '{}' while running {}. Caught as HTTP".format(args[0].path, func.__name__), exc_info=True)
            raise Http404
        except Http404:
            raise
        except Exception as e:
            logger.exception("An exception occurred processing request for '{}' while running {}. Caught as HTTP".format(args[0].path, func.__name__))
            return render_to_response(args[0], 'static/generic.html',
                             {"content": "There was an error processing your request: {}".format(str(e))})
        return result
    return wrapper
def catch_error_as_http ( func ) : @ wraps ( func ) def wrapper ( * args , * * kwargs ) : try : result = func ( * args , * * kwargs ) except exps . InputError as e : logger . warning ( "An exception occurred processing request for '{}' while running {}. Caught as HTTP" . format ( args [ 0 ] . path , func . __name__ ) , exc_info = True ) raise Http404 except Http404 : raise except Exception as e : logger . exception ( "An exception occurred processing request for '{}' while running {}. Caught as HTTP" . format ( args [ 0 ] . path , func . __name__ ) ) return render_to_response ( args [ 0 ] , 'static/generic.html' , { "content" : "There was an error processing your request: {}" . format ( str ( e ) ) } ) return result return wrapper