コード例 #1
0
ファイル: artifacts.py プロジェクト: boxingbeetle/softfab
 def putFailed(cls, fail: Failure, request: TwistedRequest) -> None:
     ex = fail.value
     if isinstance(ex, ValueError):
         request.setResponseCode(415)
         request.setHeader(b'Content-Type', b'text/plain; charset=UTF-8')
         request.write((f'{ex}\n').encode())
         request.finish()
     else:
         request.processingFailed(fail)
コード例 #2
0
ファイル: server.py プロジェクト: yteric/portia
    def processingFailed(self, reason):
        if self.is_ajax():
            log.err(reason)
            if self.site.displayTracebacks:
                body = reason.getTraceback()
            else:
                body = b"Processing Failed"

            self.setResponseCode(http.INTERNAL_SERVER_ERROR)
            self.setHeader(b'content-type', b"text/plain")
            self.setHeader(b'content-length', intToBytes(len(body)))
            self.write(body)
            self.finish()
            return reason

        return WebRequest.processingFailed(self, reason)
コード例 #3
0
ファイル: server.py プロジェクト: 9birds/portia
    def processingFailed(self, reason):
        if self.is_ajax():
            log.err(reason)
            if self.site.displayTracebacks:
                body = reason.getTraceback()
            else:
                body = b"Processing Failed"

            self.setResponseCode(http.INTERNAL_SERVER_ERROR)
            self.setHeader(b'content-type', b"text/plain")
            self.setHeader(b'content-length', intToBytes(len(body)))
            self.write(body)
            self.finish()
            return reason

        return WebRequest.processingFailed(self, reason)
コード例 #4
0
ファイル: request.py プロジェクト: Pusnow/Yuzuki
 def processingFailed(self, reason):
     if DEBUG:
         return Request.processingFailed(self, reason)
     else:
         if issubclass(reason.type, YuzukiException):
             exc = reason.value
             self.logger.warning(reason)
             self.setResponseCode(exc.status)
             body = generate_error_message(self, exc.status, exc.message)
         else:
             self.logger.error(reason)
             self.setResponseCode(INTERNAL_SERVER_ERROR)
             body = generate_error_message(self, INTERNAL_SERVER_ERROR, u"서버 에러가 발생하였습니다.")
         if issubclass(reason.type, SQLAlchemyError):
             YuzukiRequest.dbsession.close()
             YuzukiRequest.dbsession = DatabaseHelper.session()
         body = body.encode("UTF-8")
         self.setHeader(b'content-type', b"text/html")
         self.setHeader(b'content-length', intToBytes(len(body)))
         self.write(body)
         self.finish()
         return reason
コード例 #5
0
 def processingFailed(self, reason):
     if DEBUG:
         return Request.processingFailed(self, reason)
     else:
         if issubclass(reason.type, YuzukiException):
             exc = reason.value
             self.logger.warning(reason)
             self.setResponseCode(exc.status)
             body = generate_error_message(self, exc.status, exc.message)
         else:
             self.logger.error(reason)
             self.setResponseCode(INTERNAL_SERVER_ERROR)
             body = generate_error_message(self, INTERNAL_SERVER_ERROR,
                                           u"서버 에러가 발생하였습니다.")
         if issubclass(reason.type, SQLAlchemyError):
             YuzukiRequest.dbsession.close()
             YuzukiRequest.dbsession = DatabaseHelper.session()
         body = body.encode("UTF-8")
         self.setHeader(b'content-type', b"text/html")
         self.setHeader(b'content-length', intToBytes(len(body)))
         self.write(body)
         self.finish()
         return reason
コード例 #6
0
ファイル: site.py プロジェクト: foamdino/warp
 def processingFailed(self, reason):
     rv = Request.processingFailed(self, reason)
     store.rollback()
     store.commit()
     return rv