public Object getFieldValue(_Fields field) { switch (field) { case EXCEPTION_DATA: return getExceptionData(); case SERVER_INFO: return getServerInfo(); case NEXT_EXCEPTIONS: return getNextExceptions(); } throw new IllegalStateException(); }
public static GFXDException newGFXDException(String sqlState, Throwable t, String serverInfo, Object... args) { GFXDExceptionData payload = new GFXDExceptionData(getMessageUtil() .getCompleteMessage(sqlState, args), getSQLStateFromIdentifier(sqlState), getSeverityFromIdentifier(sqlState)); GFXDException gfxde = new GFXDException(payload, serverInfo); if (t != null) { if (t instanceof GFXDException) { GFXDException next = (GFXDException)t; gfxde.addToNextExceptions(next.getExceptionData()); if (next.getNextExceptions() != null) { gfxde.getNextExceptions().addAll(next.getNextExceptions()); } } else { gfxde.initCause(t); } } return gfxde; }
public static SQLException newSQLException(GFXDException gfxde) { GFXDExceptionData payload = gfxde.getExceptionData(); SQLException sqle = newSQLException(payload, gfxde.getCause(), gfxde.getServerInfo()); // since GFXDException is always a wrapper, no need to record the stack sqle.setStackTrace(gfxde.getStackTrace()); // build next exceptions List<GFXDExceptionData> nextList = gfxde.getNextExceptions(); SQLException current = sqle, next; if (nextList != null) { for (GFXDExceptionData nextData : nextList) { // check for server stack indicator if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals( nextData.getSqlState())) { Throwable cause = sqle; while (cause.getCause() != null) { cause = cause.getCause(); } cause.initCause(new ServerException(nextData.getReason())); } else { next = newSQLException(nextData, null, null); current.setNextException(next); current = next; } } } return sqle; }