java-commons/muscript/src/main/java/io/gitlab/jfronny/muscript/data/dynamic/DynamicTypeConversionExcept...

21 lines
807 B
Java

package io.gitlab.jfronny.muscript.data.dynamic;
import io.gitlab.jfronny.muscript.error.LocationalException;
public class DynamicTypeConversionException extends RuntimeException {
private static final String MESSAGE1 = "Could not convert dynamic of type ";
private static final String MESSAGE2 = " to ";
private final String target;
private final String actual;
public DynamicTypeConversionException(String target, Dynamic<?> dynamic) {
super(MESSAGE1 + dynamic.getClass().getSimpleName() + MESSAGE2 + target);
this.target = target;
this.actual = dynamic.getClass().getSimpleName();
}
public LocationalException locational(int start, int end) {
return new LocationalException(start, end, MESSAGE1 + actual + MESSAGE2 + target, this);
}
}