def test_nested_in_traceback(self): faild = defer.Deferred() @twistit.yieldefer def func_g(): yield faild @twistit.yieldefer def func_h(): yield func_g() d = func_h() try: raise ValueError("myerror") except: faild.errback() failure = extract_failure(d) sfile = stringio.StringIO() failure.printTraceback(file=sfile) info = sfile.getvalue() self.assertIn("func_h", info) self.assertIn("func_g", info)
def _handleListenerError(self, failure, msgCtx, data, listener): """Catch errors in message listeners. Just prints out a (hopefully informative) message about any errors that may have occurred. """ print 'Unhandled error in message listener:', msgCtx, data, listener failure.printTraceback(elideFrameworkCode=1)
def gotResolverError(self, failure, protocol, message, address): if isinstance(failure.value, (dns.DomainError, dns.AuthoritativeDomainError)): message.rCode = dns.ENAME else: message.rCode = dns.ESERVER print 'HEY IT IS A FAILURE' failure.printTraceback() self.sendReply(protocol, message, address) if self.verbose: log.msg("Lookup failed")
def test_printStringExceptions(self): """ L{Failure.printTraceback} should write out stack and exception information, even for string exceptions. """ failure = self._getStringFailure() output = StringIO.StringIO() failure.printTraceback(file=output) lines = output.getvalue().splitlines() # The last line should be the value of the raised string self.assertEqual(lines[-1], self._stringException)
def _gotError(self, failure, request, methodName, ns): self.info('_gotError %s %s', failure, failure.value) e = failure.value status = 500 if isinstance(e, errorCode): status = e.status else: failure.printTraceback() response = soap_lite.build_soap_error(status) self._sendResponse(request, response, status=status)
def on_failure(self, failure, request): """ Handle exceptions raised during RestResource processing :param failure: ``twisted.python.failure.Failure`` instance :param request: ``twisted.web.server.Request`` instance """ fq_name = self.__module__ + '.' + self.__class__.__name__ file_path = abspath(inspect.getfile(self.__class__)) if failure.check(CancelledError): # the request / deferred chain has been cancelled early. # doesn't matter if we respond no one is listening. rstr = err = 'Request was cancelled' elif failure.check(_DefGen_Return): failure.printBriefTraceback() err = dedent(''' Received a Deferred Generator Response from Resource (%s) in the method: [%s] .................................... This indicates you may be missing a yield statement and the decorator `@defer.inlineCallbacks`. File: %s If you do not have a yield statement, you should use a regular `return` statement and remove `defer.returnValue()` ''' % (fq_name, request.method_called, file_path)).strip() log.err(err + ' - ' + failure.getErrorMessage()) rstr = self.ERROR_CLASS( INTERNAL_SERVER_ERROR, err, failure.getErrorMessage(), is_logged=False ).render(request) else: log.err('Exception in Resource (%s) [%s] <%s> - %s' % ( fq_name, request.method_called, file_path, failure.getErrorMessage())) failure.printTraceback() rstr = self.ERROR_CLASS( INTERNAL_SERVER_ERROR, 'Unhandled Error', 'Exception in Resource (%s) [%s] <%s> - %s' % ( fq_name, request.method_called, file_path, failure.getTraceback()), is_logged=False ).render(request) if request.finished: return request.write(rstr) request.finish()
def failed(self, failure): """Callback for when the job fails.""" failure.printTraceback() self.terminated()
def testFailed(failure): log.err("Failed in running a test inside a test list") failure.printTraceback()
def errorRunningTests(failure): log.err("There was an error in running a test") failure.printTraceback()
def itererror(failure, message): logger.info("itererror message: %s" % message) #logger.info("DEBUG: %s" % failure) #logger.info("DEBUG: %s" % dir(failure) failure.printTraceback() return failure
def _handle_enqueue_error(self, failure): self._enqueue_in_progress = False failure.printTraceback()
def _errorCall(failure): assert isinstance(callId, int), "%r" % (callId,) failure.printTraceback() self.sendUI('exception', callId, str(failure))
def _handle_error(self, failure): failure.printTraceback() return failure