Search in sources :

Example 1 with Skript

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;
    };
}
Also used : PrintWriter(java.io.PrintWriter) Arrays(java.util.Arrays) Array(java.lang.reflect.Array) StringWriter(java.io.StringWriter) Member(java.lang.reflect.Member) ExpressionList(ch.njol.skript.lang.ExpressionList) Set(java.util.Set) HashMap(java.util.HashMap) Field(java.lang.reflect.Field) Constructor(java.lang.reflect.Constructor) Function(java.util.function.Function) SyntaxElementInfo(ch.njol.skript.lang.SyntaxElementInfo) Parameter(ch.njol.skript.lang.function.Parameter) HashSet(java.util.HashSet) Objects(java.util.Objects) Expression(ch.njol.skript.lang.Expression) Stream(java.util.stream.Stream) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) Skript(ch.njol.skript.Skript) Literal(ch.njol.skript.lang.Literal) Method(java.lang.reflect.Method) UnparsedLiteral(ch.njol.skript.lang.UnparsedLiteral) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Aggregations

Skript (ch.njol.skript.Skript)1 Expression (ch.njol.skript.lang.Expression)1 ExpressionList (ch.njol.skript.lang.ExpressionList)1 Literal (ch.njol.skript.lang.Literal)1 SyntaxElementInfo (ch.njol.skript.lang.SyntaxElementInfo)1 UnparsedLiteral (ch.njol.skript.lang.UnparsedLiteral)1 Parameter (ch.njol.skript.lang.function.Parameter)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Array (java.lang.reflect.Array)1 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1 Member (java.lang.reflect.Member)1 Method (java.lang.reflect.Method)1 Modifier (java.lang.reflect.Modifier)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Objects (java.util.Objects)1