Search in sources :

Example 1 with NoResultsException

use of org.skife.jdbi.v2.exceptions.NoResultsException in project dropwizard by dropwizard.

the class LoggingDBIExceptionMapperTest method testSqlExceptionIsCause.

@Test
public void testSqlExceptionIsCause() throws Exception {
    StatementContext statementContext = mock(StatementContext.class);
    RuntimeException runtimeException = new RuntimeException("DB is down");
    SQLException sqlException = new SQLException("DB error", runtimeException);
    DBIException dbiException = new NoResultsException("Unable get a result set", sqlException, statementContext);
    dbiExceptionMapper.logException(9812, dbiException);
    verify(logger).error("Error handling a request: 0000000000002654", sqlException);
    verify(logger).error("Error handling a request: 0000000000002654", runtimeException);
    verify(logger, never()).error("Error handling a request: 0000000000002654", dbiException);
}
Also used : NoResultsException(org.skife.jdbi.v2.exceptions.NoResultsException) SQLException(java.sql.SQLException) DBIException(org.skife.jdbi.v2.exceptions.DBIException) StatementContext(org.skife.jdbi.v2.StatementContext) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)1 Test (org.junit.Test)1 StatementContext (org.skife.jdbi.v2.StatementContext)1 DBIException (org.skife.jdbi.v2.exceptions.DBIException)1 NoResultsException (org.skife.jdbi.v2.exceptions.NoResultsException)1