```java
 public Result thenApplyWithContext(Function<Result, Result> fn) {
        this.thenApply(fn.compose(beforeContext).andThen(afterContext));
        // You may need to return a new Result instance representing the next async stage,
        // like thenApply will return a new CompletableFuture.
        return this;
    }
```

to

```java
```java
 public Result thenApplyWithContext(BiFunction<Throwable, Result> fn) {
        this.handle(fn);
        // You may need to return a new Result instance representing the next async stage,
        // like thenApply will return a new CompletableFuture.
        return this;
    }
```
```
public Throwable getException() {
        return exception;
    }
    @Override
    public void setException(Throwable e) {
        this.exception = e;
    }
    @Override
    public boolean hasException() {
        return exception != null;
    }
    @Override
    public Map<String, String> getAttachments() {
        return attachments;
    }
    /**
     * Append all items from the map into the attachment, if map is empty then nothing happens
     *
     * @param map contains all key-value pairs to append
     */
    @Override
    public void setAttachments(Map<String, String> map) {
        this.attachments = map == null ? new HashMap<String, String>() : map;
    }
    @Override
    public void addAttachments(Map<String, String> map) {
        if (map == null) {
            return;
        }
        if (this.attachments == null) {