tech.ydb.yoj.databind.schema.FieldValueException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yoj-databind Show documentation
Show all versions of yoj-databind Show documentation
Core data-binding logic used by YOJ (YDB ORM for Java) to convert
between Java objects and database rows (or anything representable by
a Java Map, really).
The newest version!
package tech.ydb.yoj.databind.schema;
import javax.annotation.Nullable;
import static java.lang.String.format;
public final class FieldValueException extends BindingException {
public FieldValueException(@Nullable Throwable cause, String fieldName, Object containingObject) {
super(cause, ex -> message(fieldName, containingObject, ex));
}
private static String message(String fieldName, Object obj, Throwable ex) {
String safeObj;
try {
safeObj = String.valueOf(obj);
} catch (Exception toStrEx) {
safeObj = format("[value of %s; threw on toString(): %s]", obj.getClass(), toStrEx);
}
return format("Could not get value of field \"%s\" from %s%s", fieldName, safeObj, ex == null ? "" : ": " + ex);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy