Search in sources :

Example 1 with NoResultsException

use of org.jdbi.v3.core.result.NoResultsException in project dropwizard by dropwizard.

the class LoggingJdbiExceptionMapperTest method testSqlExceptionIsCause.

@Test
void testSqlExceptionIsCause() throws Exception {
    StatementContext statementContext = mock(StatementContext.class);
    RuntimeException runtimeException = new RuntimeException("DB is down");
    SQLException sqlException = new SQLException("DB error", runtimeException);
    JdbiException jdbiException = new NoResultsException("Unable get a result set", sqlException, statementContext);
    jdbiExceptionMapper.logException(9812, jdbiException);
    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", jdbiException);
}
Also used : NoResultsException(org.jdbi.v3.core.result.NoResultsException) SQLException(java.sql.SQLException) JdbiException(org.jdbi.v3.core.JdbiException) StatementContext(org.jdbi.v3.core.statement.StatementContext) Test(org.junit.jupiter.api.Test)

Aggregations

SQLException (java.sql.SQLException)1 JdbiException (org.jdbi.v3.core.JdbiException)1 NoResultsException (org.jdbi.v3.core.result.NoResultsException)1 StatementContext (org.jdbi.v3.core.statement.StatementContext)1 Test (org.junit.jupiter.api.Test)1