Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper logging for withSafeSideEffect #326

Open
williamwjs opened this issue Nov 30, 2022 · 0 comments
Open

Proper logging for withSafeSideEffect #326

williamwjs opened this issue Nov 30, 2022 · 0 comments

Comments

@williamwjs
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant