Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import javax.xml.parsers.ParserConfigurationException;

import org.hibernate.JDBCException;
import org.hibernate.exception.ConstraintViolationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

import railo.commons.io.res.Resource;
import railo.commons.lang.types.RefBoolean;
import railo.loader.engine.CFMLEngineFactory;
import railo.loader.util.Util;
import railo.runtime.Component;
import railo.runtime.MappingImpl;
import railo.runtime.PageContext;
Expand Down Expand Up @@ -296,18 +298,26 @@ public static Array toArray(Argument arg) {
}

public static PageException toPageException(Throwable t) {
if (!(t instanceof JDBCException))
return caster().toPageException(t);


JDBCException j = (JDBCException)t;
String message = j.getMessage();
Throwable cause = j.getCause();
if(cause != null) {
message += " [" + cause.getMessage() + "]";
PageException pe = caster().toPageException(t);;
if (t instanceof org.hibernate.HibernateException) {
org.hibernate.HibernateException he = (org.hibernate.HibernateException)t;
Throwable cause = he.getCause();
if(cause != null) {
pe = caster().toPageException( cause );
ExceptionUtil.setAdditional(pe, CommonUtil.createKey("hibernate exception"), t );
}
}
return CFMLEngineFactory.getInstance().getExceptionUtil().createDatabaseException(message, new SQLImpl(j.getSQL()));

if ( t instanceof JDBCException ) {
JDBCException je = (JDBCException)t;
ExceptionUtil.setAdditional(pe, CommonUtil.createKey("sql"), je.getSQL());
}
if( t instanceof ConstraintViolationException) {
ConstraintViolationException cve = (ConstraintViolationException)t;
if(!Util.isEmpty(cve.getConstraintName())) {
ExceptionUtil.setAdditional(pe, CommonUtil.createKey("constraint name"), cve.getConstraintName());
}
}
return pe;
}
public static Serializable toSerializable(Object obj) throws PageException {
return caster().toSerializable(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ public void flush(PageContext pc) throws PageException {
try {
session().flush();
}
catch(ConstraintViolationException cve){
PageException pe = ExceptionUtil.createException(this,null,cve);
if(!Util.isEmpty(cve.getConstraintName())) {
ExceptionUtil.setAdditional(pe, CommonUtil.createKey("constraint name"), cve.getConstraintName());
}
throw pe;
}
catch(Throwable t) {
throw CommonUtil.toPageException(t);
}
Expand Down