Ejemplo n.º 1
0
            except Exception, e:
                # Caught a non-DAVError
                if self._catch_all_exceptions:
                    # Catch all exceptions to return as 500 Internal Error
                    traceback.print_exc(
                        10,
                        environ.get("wsgi.errors") or sys.stderr)
                    raise asDAVError(e)
                else:
                    util.warn("ErrorPrinter: caught Exception")
                    traceback.print_exc(10, sys.stderr)
                    raise
        except DAVError, e:
            _logger.debug("caught %s" % e)

            status = getHttpStatusString(e)
            # Dump internal errors to console
            if e.value == HTTP_INTERNAL_ERROR:
                print >> sys.stdout, "ErrorPrinter: caught HTTPRequestException(HTTP_INTERNAL_ERROR)"
                traceback.print_exc(10,
                                    environ.get("wsgi.errors") or sys.stdout)
                print >> sys.stdout, "e.srcexception:\n%s" % e.srcexception
            elif e.value in (HTTP_NOT_MODIFIED, HTTP_NO_CONTENT):
                #                util.log("ErrorPrinter: forcing empty error response for %s" % e.value)
                # See paste.lint: these code don't have content
                start_response(status, [
                    ("Content-Length", "0"),
                    ("Date", util.getRfc1123Time()),
                ])
                yield ""
                return
Ejemplo n.º 2
0
                raise
            except Exception, e:
                # Caught a non-DAVError 
                if self._catch_all_exceptions:
                    # Catch all exceptions to return as 500 Internal Error
#                    traceback.print_exc()
                    util.warn(traceback.format_exc())
                    raise asDAVError(e)
                else:
                    util.warn("ErrorPrinter: caught Exception")
                    util.warn(traceback.format_exc())
                    raise
        except DAVError, e:
            _logger.debug("caught %s" % e)

            status = getHttpStatusString(e)
            # Dump internal errors to console
            if e.value == HTTP_INTERNAL_ERROR:
                util.warn(traceback.format_exc())
                util.warn("e.srcexception:\n%s" % e.srcexception)
            elif e.value in (HTTP_NOT_MODIFIED, HTTP_NO_CONTENT):
#                util.log("ErrorPrinter: forcing empty error response for %s" % e.value)
                # See paste.lint: these code don't have content
                start_response(status, [("Content-Length", "0"),
                                        ("Date", util.getRfc1123Time()),
                                        ])
                yield ""
                return

            # If exception has pre-/post-condition: return as XML response, 
            # else return as HTML