fix(muscript): disable formatting for intentional exceptions
This commit is contained in:
parent
785e5ca5c5
commit
26edf52944
|
@ -0,0 +1,7 @@
|
|||
package io.gitlab.jfronny.muscript.data.additional.libs;
|
||||
|
||||
public class IntentionalException extends RuntimeException {
|
||||
public IntentionalException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -385,7 +385,7 @@ public class StandardLib {
|
|||
.and(callable(null));
|
||||
public static DNull fail(DList args) {
|
||||
if (args.size() > 1) throw new SignatureDesyncException("fail");
|
||||
throw new RuntimeException(args.isEmpty() ? "Failed" : args.get(0).asString().getValue());
|
||||
throw new IntentionalException(args.isEmpty() ? "Failed" : args.get(0).asString().getValue());
|
||||
}
|
||||
|
||||
// Util
|
||||
|
|
|
@ -18,7 +18,7 @@ public non-sealed interface DCallable extends Dynamic {
|
|||
if (!TypeMatcher.match(signature, argTypes)) {
|
||||
List<DTypeCallable.Arg> extraArgs = argTypes.stream().map(s -> new DTypeCallable.Arg(null, s, false)).toList();
|
||||
DTypeCallable callSignature = new DTypeCallable(extraArgs, null);
|
||||
throw new IllegalArgumentException("Signature mismatch for " + getName() + ": expected <" + signature + "> but got <" + callSignature + ">");
|
||||
throw new SignatureMismatchException(getName(), signature, callSignature);
|
||||
}
|
||||
}
|
||||
return getValue().apply(args);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package io.gitlab.jfronny.muscript.data.dynamic;
|
||||
|
||||
import io.gitlab.jfronny.muscript.data.dynamic.type.DType;
|
||||
import io.gitlab.jfronny.muscript.data.dynamic.type.DTypeCallable;
|
||||
|
||||
public class SignatureMismatchException extends IllegalArgumentException {
|
||||
public SignatureMismatchException(String method, DType expected, DTypeCallable actual) {
|
||||
super("Signature mismatch for " + method + ": expected <" + expected + "> but got <" + actual + ">");
|
||||
}
|
||||
}
|
|
@ -11,11 +11,12 @@ import io.gitlab.jfronny.muscript.ast.extensible.ExtensibleNumberExpr;
|
|||
import io.gitlab.jfronny.muscript.ast.extensible.ExtensibleStringExpr;
|
||||
import io.gitlab.jfronny.muscript.ast.number.*;
|
||||
import io.gitlab.jfronny.muscript.ast.string.*;
|
||||
import io.gitlab.jfronny.muscript.core.CodeLocation;
|
||||
import io.gitlab.jfronny.muscript.core.IDynamic;
|
||||
import io.gitlab.jfronny.muscript.core.LocationalException;
|
||||
import io.gitlab.jfronny.muscript.core.StackFrame;
|
||||
import io.gitlab.jfronny.muscript.data.additional.context.Scope;
|
||||
import io.gitlab.jfronny.muscript.data.additional.libs.IntentionalException;
|
||||
import io.gitlab.jfronny.muscript.data.additional.libs.SignatureDesyncException;
|
||||
import io.gitlab.jfronny.muscript.data.dynamic.*;
|
||||
import io.gitlab.jfronny.muscript.data.dynamic.context.DynamicSerializer;
|
||||
import io.gitlab.jfronny.muscript.data.dynamic.type.DTypeCallable;
|
||||
|
@ -235,6 +236,8 @@ public class Runtime {
|
|||
yield dc.call(arg);
|
||||
} catch (LocationalException le) {
|
||||
throw le.appendStack(new StackFrame.Raw(expr.location().file(), dc.getName(), e.callable().location().chStart()));
|
||||
} catch (IntentionalException | SignatureDesyncException | SignatureMismatchException ex) {
|
||||
throw new LocationalException(expr.location(), ex.getMessage(), ex);
|
||||
} catch (RuntimeException ex) {
|
||||
throw locationalException(expr, ex.getMessage(), ex);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue