Skip to content

Not receiving the rejectedObject in .error() #1

@rabbishuki

Description

@rabbishuki

First of all, thanks for this simple and useful piece of code.

I found a little problem.
When rejecting a promise, the object I get in the .error() function is the OnErrorListener object instead of the rejected Object that I sent.

My code (abbreviated) looks like this:

public Promise example() {
    Promise p = new Promise();
    p.reject("new Error");
    return p;
}

example
    .then(res -> handleSuccess(res))
    .error(res -> handleError(res)) // `res` doesn't equal "new Error".

So I dug into your code and changed the following line

handler.post(() -> handleError(onErrorListener));

to:

    handler.post(() -> handleError(rejectedObject)); 

And now it works as expected.

Is that what was supposed to be done?
or did I do something that will bite me back later?

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