de.chojo.sadu.mapper.exceptions.MappingException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sadu-mapper Show documentation
Show all versions of sadu-mapper Show documentation
SADU module to map values received from a database to java objects using the queries module.
The newest version!
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Copyright (C) RainbowDashLabs and Contributor
*/
package de.chojo.sadu.mapper.exceptions;
import de.chojo.sadu.mapper.util.Results;
import java.io.Serial;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class MappingException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1;
public MappingException(String message) {
super(message);
}
public static MappingException create(ResultSetMetaData meta) throws SQLException {
return new MappingException("No mapper present for %s of types %s".formatted(
String.join(", ", Results.columnNames(meta)),
String.join(", ", Results.columnTypes(meta)))
);
}
public static MappingException create(Class clazz, ResultSetMetaData meta) throws SQLException {
return new MappingException("No mapper present for columns %s of types %s to %s".formatted(
String.join(", ", Results.columnNames(meta)),
String.join(", ", Results.columnTypes(meta)),
clazz.getName())
);
}
}