muScript: catch runtime exceptions and wrap in LocationalException

This commit is contained in:
Johannes Frohnmeyer 2023-03-11 17:01:03 +01:00
parent 3e143c4a92
commit 4be87948a3
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import io.gitlab.jfronny.muscript.annotations.CanThrow;
import io.gitlab.jfronny.muscript.annotations.UncheckedDynamic;
import io.gitlab.jfronny.muscript.data.Scope;
import io.gitlab.jfronny.muscript.data.dynamic.*;
import io.gitlab.jfronny.muscript.error.LocationalException;
import java.util.*;
import java.util.stream.Stream;
@ -30,6 +31,8 @@ public class Call extends DynamicExpr {
.apply(DFinal.of(args.stream().flatMap(e -> e.get(dataRoot)).toArray(Dynamic[]::new)));
} catch (DynamicTypeConversionException e) {
throw e.locational(chStart, chEnd);
} catch (RuntimeException e) {
throw new LocationalException(chStart, chEnd, "Could not perform call successfully", e);
}
}