Skip to content

Commit

Permalink
refactor(TryConsumer): add log
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Sep 2, 2024
1 parent f958f0c commit 526f296
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package org.bsc.langgraph4j.utils;

import lombok.extern.slf4j.XSlf4j;

import java.util.function.Consumer;

@FunctionalInterface
public interface TryConsumer<T, Ex extends Throwable> extends Consumer<T> {
org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TryConsumer.class);

void tryAccept( T t ) throws Ex;

default void accept( T t ) {
try {
tryAccept(t);
} catch (Throwable ex) {
log.error(ex.getMessage(), ex);
throw new RuntimeException(ex);
}
}
Expand Down

0 comments on commit 526f296

Please sign in to comment.