def fromFailure(fail, defaultCode=None, **kwargs): """ Returns an error status notification based on the supplied L{twisted.python.failure.Failure} object. @return: L{IStatus} in an error state based upon the supplied failure object. """ # prevent circular import from rtmpy import exc cls = type(fail.value) code = exc.codeByClass(cls) or exc.codeByClass(defaultCode) or defaultCode description = fail.getErrorMessage() return error(code, description, **kwargs)
def error(code, description, **kwargs): """ Returns a L{IStatus} in an error state. Use this if you want to return a failure notification for a given operation. @param code: The code of the status. See L{rtmpy.status.codes} for a list of valid values. @param description: A humanised description of the successful operation. @param kwargs: A C{dict} of values that will be added to the status object and will be dispatched to the receiving endpoint. """ # prevent circular import from rtmpy import exc code = exc.codeByClass(code) or code return Status(STATUS_ERROR, code, description, **kwargs)