Add tryIgnore, tryCatch methods

This commit is contained in:
2025-05-27 16:44:45 -05:00
parent d63f13bb55
commit 437448fd81
2 changed files with 65 additions and 0 deletions

View File

@ -26,6 +26,8 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeVoidVoidMethod;
/*******************************************************************************
@ -183,4 +185,41 @@ public class ExceptionUtils
}
return (rs);
}
/***************************************************************************
**
***************************************************************************/
public static void tryIgnore(UnsafeVoidVoidMethod<?> method)
{
try
{
method.run();
}
catch(Throwable t)
{
///////////////////////////
// ignore, as name says! //
///////////////////////////
}
}
/***************************************************************************
**
***************************************************************************/
public static void tryCatch(UnsafeVoidVoidMethod<?> method, Consumer<Throwable> catcher)
{
try
{
method.run();
}
catch(Throwable t)
{
catcher.accept(t);
}
}
}