Skip to content

Looking for solution to stop the task chain and not trigger onFailure or recover #221

@haiweiwang73

Description

@haiweiwang73

Is there a way to pause the task sequence, check condition and cancel out the sequence.

Task<OrderDatagram> t1 = Task.value(orderData);

        Task<OrderDatagram> t2 = t1.andThen( d -> d.setCurrency(Optional.of("dollars")));

        Task<OrderDatagram> t3 = t2.andThen( d -> {
            if(d.getCurrency().equals("dollars")){
                System.out.println("The verification is not passed throw error");
//// This is the part doesnt work as what I think it is. Is there a way to stop the process fro the rest of the task and not trigger the onFailure in temp ??
                t2.cancel(new OrderDatagramValidationException.Item.ExistsException(1,"abc",1));
            }
        });

        Task<OrderDatagram> temp =  t3.andThen( t -> {
            throw new Exception();
        }).onFailure( t->{
            throw new Exception();
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions