Skip to content

Commit 4d8060d

Browse files
committed
handle final key outside try-catch
1 parent ea3e168 commit 4d8060d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

value/core/src/main/java/me/hsgamer/topper/value/core/ValueProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ static <K, V> ValueProvider<K, V> error(@NotNull String errorMessage) {
3131

3232
default <RK> ValueProvider<RK, V> beforeApply(Function<@NotNull RK, @Nullable K> mapper) {
3333
return (rawKey, callback) -> {
34+
K key;
3435
try {
35-
K key = mapper.apply(rawKey);
36+
key = mapper.apply(rawKey);
3637
if (key == null) {
3738
callback.accept(ValueWrapper.notHandled());
3839
return;
3940
}
40-
accept(key, callback);
4141
} catch (Throwable e) {
4242
callback.accept(ValueWrapper.error("An error occurred while mapping the key", e));
43+
return;
4344
}
45+
accept(key, callback);
4446
};
4547
}
4648

0 commit comments

Comments
 (0)