use of com.palantir.util.sql.VerboseSQLException in project atlasdb by palantir.
the class BasicSQL method wrapSQLExceptionWithVerboseLogging.
private static PalantirSqlException wrapSQLExceptionWithVerboseLogging(final SQLException sqlEx, String sql, Object[] args) {
try {
StringBuilder why = new StringBuilder();
why.append(// $NON-NLS-1$ //$NON-NLS-2$
"While attempting to execute the SQL '" + sql + "' we caught a SQLException.\n" + // $NON-NLS-1$
"The SQL was executed with the following bind args:\n");
BasicSQLUtils.toStringSqlArgs(why, args);
// $NON-NLS-1$
why.append("End of verbose SQLException error message");
return PalantirSqlException.create(new VerboseSQLException(sqlEx, why.toString()));
} catch (Throwable e) {
// make sure we don't interfere with the real error
SqlLoggers.LOGGER.error(// $NON-NLS-1$
"Trapped an exception while printing out information about an exception. " + "No client requests were harmed.", // $NON-NLS-1$
e);
// $NON-NLS-1$
SqlLoggers.LOGGER.error("Printing SQLException now so it doesn't get lost", sqlEx);
}
return PalantirSqlException.create(sqlEx);
}
use of com.palantir.util.sql.VerboseSQLException in project atlasdb by palantir.
the class BasicSQL method wrapSQLExceptionWithVerboseLogging.
private static PalantirSqlException wrapSQLExceptionWithVerboseLogging(final PalantirSqlException sqlEx, String sql, Object[] args) {
try {
if (sqlEx.getCause() == null || !(sqlEx.getCause() instanceof SQLException)) {
return sqlEx;
}
StringBuilder why = new StringBuilder();
why.append(// $NON-NLS-1$ //$NON-NLS-2$
"While attempting to execute the SQL '" + sql + "' we caught a SQLException.\n" + // $NON-NLS-1$
"The SQL was executed with the following bind args:\n");
BasicSQLUtils.toStringSqlArgs(why, args);
// $NON-NLS-1$
why.append("End of verbose SQLException error message");
return PalantirSqlException.create(new VerboseSQLException((SQLException) sqlEx.getCause(), why.toString()));
} catch (Throwable e) {
// make sure we don't interfere with the real error
SqlLoggers.LOGGER.error(// $NON-NLS-1$
"Trapped an exception while printing out information about an exception. " + "No client requests were harmed.", // $NON-NLS-1$
e);
// $NON-NLS-1$
SqlLoggers.LOGGER.error("Printing SQLException now so it doesn't get lost", sqlEx);
}
return sqlEx;
}
Aggregations