Skip to content

Rejection propagation is incorrect #3

@stakira

Description

@stakira
local deferred = require("deferred")

local d = deferred:new()

local function f1()
    return d
end

local function f2()
    return f1():next(
        function(res)
            return (res or "") .. "f2"
        end,
        function(err)
            print("f2 err")
            return err
        end
    )
end

local function f3()
    return f2():next(
        function(res)
            return res .. "f3"
        end,
        function(err)
            print("f3 err")
            return err
        end
    )
end

f3():next(
    function(res)
        print("suc", res)
    end,
    function(err)
        print("fail", err)
    end
)

d:reject("fail error reject")
Failure: fail error reject
suc f2f3

Tried both Lua 5.1.5 and 5.2.4, same results.

Even though I don't know if returning in error callback is the way to pass error to next stage, obviously error handling branch in f2() doesn't get called at all. Could you please explain this? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions