示例#1
0
文件: __init__.py 项目: Arlex/rtmpy
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)
示例#2
0
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)
示例#3
0
文件: __init__.py 项目: Arlex/rtmpy
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)
示例#4
0
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)