def unpack_deferred_list_result(results): for successful, result in results: if not successful: error.handle_failure(None, result, "Failed rendering inline model") continue yield result
def _processing_error_handler(self, f, call): error.handle_failure( self, f, 'Failed to perfrom the ProcessingCall. ' 'Method being processed: %r, args: %r, kwargs: %r', call.method.__name__, call.args, call.kwargs) self._set_state(ChannelState.recording) self._processing_chain.insert(0, call)
def _handle_failure_updating(self, state, fail, alert): db = state.medium.get_database() if fail.check(NotFoundError): return db.save_document(alert) error.handle_failure(self, fail, "Failed updating the state of persitent" " alert. Doc: %r", alert)
def _starting_failed(self, state, fail): error.handle_failure(self, fail, 'Starting failed, cancelling') msg = message.Cancellation(reason=fail) f = self._release_allocation() f.add_callback(fiber.drop_param, state.medium.defect, msg) return f
def _print_log(self, param, stage): self.log('Finished stage %s. Defer result at this point: %r', stage.name, param) if isinstance(param, failure.Failure): error.handle_failure(self, param, 'Failure in stage %s: ', stage.name) self._failures.append(param)
def _action_errback(self, fail, action, model): if IAttribute.providedBy(model) and fail.check(ValueError): return error.handle_failure(self, fail, "Failed running action name: %s on model: %r", action.name, model) self.fail("Calling action %s on model %s failed, look at logs." % (action.name, model.identity, ))
def nice_error_failed(failure): error.handle_failure(None, failure, "Failure during error rendering") # Do what we can... data = str(payload) if response.can_update_headers: response.force_mime_type("text/plain") response.set_length(len(data)) return data
def _bootstrap_failure(fail, agency, queue=None): error.handle_failure(agency, fail, 'Agency bootstrap failed, exiting.') reason = error.get_failure_message(fail) if queue: queue.put((1, reason)) global _exit_code _exit_code = 1 agency.kill(stop_process=True)
def _spawn_agent_failed(self, state, fail, desc, alert_name=None): error.handle_failure(self, fail, "Spawning agent failed! " "I will remove the descriptor.") if alert_name: self.info("raising alert %s", alert_name) self.raise_alert(alert_name, error.get_failure_message(fail)) f = self.get_document(desc.doc_id) f.add_callback(self.delete_document) f.add_both(fiber.override_result, None) return f
def _writing_errback(self, fail, mime_type, model): if fail.check(NotSupported): self.info("Model %r doesn't support fetching items", model) return error.handle_failure( self, fail, "Failed writing the model for the mime type: %r, \n" "model: %r\nsource: %r", mime_type, model, model.source) self.fail("Failed writing model, look at logs.")
def _error_handler(self, f, method): if f.check(defer.CancelledError, ProtocolExpired): # this is what happens when the call is cancelled by the # _call() method, just swallow it pass else: error.handle_failure(self, f, "Failed calling agent method %r", method) self._set_state(self.error_state) self.finalize(f)
def _processing_error_handler(self, f, call): if f.check(Closed): self.log("Failed performing the call because connection has " "been lost. This is normal, don't panic.") return error.handle_failure( self, f, 'Failed to perfrom the ProcessingCall. ' 'Method being processed: %r, args: %r, kwargs: %r', call.method.__name__, call.args, call.kwargs) self._set_state(ChannelState.recording) self._processing_chain.insert(0, call)
def _spawn_agent_failed(self, state, fail, desc, alert_name=None): error.handle_failure(self, fail, "Spawning agent failed! " "Agent type: %s, agent id: %s. " "I will remove the descriptor.", desc.type_name, desc.doc_id) if alert_name: self.info('Raising alert %s', alert_name) self.raise_alert(alert_name, error.get_failure_message(fail), severity=alert.Severity.critical) f = self.update_document(desc, update.delete) f.add_callback(fiber.override_result, None) f.add_errback(self._delete_descriptor_failed) return f
def handle_unserialize_failure(self, fail, raw): type_name = raw.get('.type') version = raw.get('.version') if fail.check(ConflictError): self.debug('Got conflict error when trying to upgrade the ' 'document: %s version: %s. Refetching it.', type_name, version) # probably we've already upgraded it concurrently return self.get_document(raw['_id']) error.handle_failure(self, fail, 'Asynchronous hooks of ' 'the upgrade failed. Raising NotMigratable') return failure.Failure(NotMigratable((type_name, version, )))
def nice_error_failed(failure): if failure.check(http.NotAcceptableError): request.debug("Failed to negotiate a mime type to render the " "error payload. Accepted mime types: %s. ", request.accepted_mime_types) else: error.handle_failure(None, failure, "Failure during error rendering") # Do what we can... data = str(payload) if response.can_update_headers: response.force_mime_type("text/plain") response.set_length(len(data)) return data
def _solve_err(self, state, fail): if fail.check(conflicts.UnsolvableConflict): doc = fail.value.doc if IDocument.providedBy(doc): doc_id = doc.doc_id else: doc_id = doc['_id'] state.unsolvable_conflicts.add(doc_id) self.warning('Cannot solve conflict for document id: %s. ' 'Reason: %s', doc_id, fail.value) self.raise_alert(ALERT_NAME, ', '.join(state.unsolvable_conflicts)) else: error.handle_failure(self, fail, 'Failed solving conflict.') msg = error.get_failure_message(fail) self.raise_alert(ALERT_NAME, msg, severity=alert.Severity.critical)
def connectionLost(self, reason): if reason.check(tw_error.ConnectionDone): # expected just pass return elif reason.check(tw_error.ConnectionLost): self.debug("CouchDB closed the notification listener. This might " "indicate misconfiguration. Take a look at it.") self._on_disconnected() self.reconnect() return elif reason.check(tw_error.ConnectionRefusedError): self.reconnect() return else: # FIXME handle disconnection when network is down self._on_disconnected() error.handle_failure(self, reason, 'Connection to couchdb lost with ' 'unusual reason.') self.reconnect()
def _emergency_termination(self, failure, request, response): try: msg = "Unrecovered Failure During Web Request" error.handle_failure(self, failure, msg) if response.can_update_headers: response.set_header("content-type", "text/plain") response.write("Error: %s" % failure.getErrorMessage()) if failure.check(http.HTTPError): return self._terminate(request, response, failure.value.status_code) else: return self._terminate(request, response) except Exception, e: msg = "Exception during emergency termination" error.handle_exception(self, e, msg) # We don't call _terminate() here, we already too deep in the mess return None
def _handle_failure(self, failure): error.handle_failure(self, failure, "Failure during termination")
def _handle_critical_error(self, fail): error.handle_failure(self, fail, 'Critical error occured.')
def _handle_critical_error(self, fail): self.error("I'm killing the process, goodbye!") error.handle_failure(self, fail, 'Critical error occured.') self.agency.shutdown(stop_process=True)
def _errback(self, fail): error.handle_failure(self.logger, fail, "Error handler: ")
def _add_backend_errback(self, fail, channel_type): error.handle_failure( self, fail, "Failed adding backend %r. " "I will remove it and carry on working.", channel_type ) self._backends.pop(channel_type, None)
def error_handler(logger, f): error.handle_failure(logger, f, "Error processing")
def handle_failure(failure, message, logger=None): error.handle_failure(logger, failure, message)
def _host_restart_failed(self, failure): error.handle_failure(self, failure, "Failure during host restart") self.debug("Retrying in %d seconds", HOST_RESTART_RETRY_INTERVAL) time.callLater(HOST_RESTART_RETRY_INTERVAL, self._start_host_agent_if_necessary)
def _handle_error(self, fail): error.handle_failure('script', fail, 'Error in the end') self.failed = True
def _error_handler(fail): error.handle_failure('script', fail, "Finished with exception: ")
def _error_handler(self, fail): error.handle_failure(None, fail, 'Failed processing with sqlite storage')
def log_effect_Error(failure, effect): error.handle_failure(None, failure, "Failure during effect %s execution", effect.func_name) return failure
def _authentication_failed(self, failure, request, response, resource, oldcred, location, _continuation, _args): if failure.check(http.NotAuthorizedError): return failure error.handle_failure(self, failure, "Failure during authentication") raise http.InternalServerError("Failure during authentication", cause=failure)