panda.dao.DaoException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.dao;
/**
*
*
*/
public class DaoException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DaoException() {
super();
}
public DaoException(String message) {
super(message);
}
public DaoException(Throwable cause) {
super(cause);
}
public DaoException(String message, Throwable cause) {
super(message, cause);
}
public static DaoException create(T obj, String fieldName, String name) {
return new DaoException(String.format("Fail to %s [%s]->[%s]", name,
obj == null ? "NULL object" : obj.getClass().getName(), fieldName));
}
public static DaoException create(T obj, String fieldName, String name, Exception e) {
if (e == null) {
return create(obj, fieldName, name);
}
if (e instanceof DaoException) {
return (DaoException)e;
}
return new DaoException(String.format("Fail to %s [%s]->[%s], because: '%s'", name,
obj == null ? "NULL object" : obj.getClass().getName(), fieldName, e.getMessage()), e);
}
}