use of ch.njol.skript.Skript in project skript-mirror by btk5h.
the class Util method propagateErrors.
@SuppressWarnings("ThrowableNotThrown")
public static <T, R> Function<T, R> propagateErrors(ExceptionalFunction<T, R> function) {
return t -> {
try {
return function.apply(t);
} catch (Exception e) {
Skript.warning(String.format("skript-mirror encountered a %s: %s%n" + "Run Skript with the verbosity 'very high' for the stack trace.", e.getClass().getSimpleName(), e.getMessage()));
if (Skript.logVeryHigh()) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
Skript.warning(errors.toString());
}
}
return null;
};
}
Aggregations