Skip to content

Proper logging for withSafeSideEffect #326

Description

@williamwjs

In the below snippet, there's only try...catch logic to convert it to a failed task:

default Task<T> withSafeSideEffect(final String desc, final Function1<? super T, Task<?>> func) {
return withSideEffect(desc, param -> {
try {
Task<?> task = func.apply(param);
if (task == null) {
throw new RuntimeException(desc + " returned null");
}
return task;
} catch (Throwable t) {
return Task.failure(desc, t);
}

However, it is hard to add logging on the caller side for this. Thus, the side effect may fail silently without an easy way to debug.

Could we use the LOGGER in this file to log the Throwable before line 407?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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