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)
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)
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)
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
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
def processingFailed(self, reason): rv = Request.processingFailed(self, reason) store.rollback() store.commit() return rv