Example #1
0
    def process_exception(self, request, exception):
        """
        @type request HttpRequest
        @type exception Exception
        """
        env = ""
        if request.GET.has_key("__env"):
            env = request.GET["__env"]

        if env == "" and request.is_ajax():
            env = "ajax"

        response = HttpResponse()
        response.status_code = 500
        if env == "ajax" or env == "json" or env == "partial":
            response.creamed = True
            response.content = renderAjaxException(request, exception)
        elif env == "ajaxform":
            response.creamed = True
            response.content = render_to_string(
                "decorator/ajaxform.html", {"jsonData": renderAjaxException(request, exception)}
            )
        else:
            logging.getLogger("cream").exception(exception)

            if DEBUG:
                raise exception
            response.content = render_to_string(
                "decorator/exception.html", {"request": request, "exception": exception}
            )

        return response