private TeiidSQLException(SQLException ex, String message, boolean addChildren) {
super(message, ex.getSQLState() == null ? SQLStates.DEFAULT : ex.getSQLState(), ex.getErrorCode());
if (addChildren) {
SQLException childException = ex; // this a child to the SQLException constructed from reason
while (childException != null) {
if (childException instanceof TeiidSQLException) {
super.setNextException(ex);
break;
}
super.setNextException(new TeiidSQLException(childException, getMessage(childException, null),false));
childException = childException.getNextException();
}
}
}