TrapException (Apache Tomcat 11.0.25 API Documentation)
Description: declaration: package: org.apache.tomcat.jdbc.pool, class: TrapException

# Class TrapException

java.lang.Object
org.apache.tomcat.jdbc.pool.JdbcInterceptor
org.apache.tomcat.jdbc.pool.TrapException

All Implemented Interfaces:
  `InvocationHandler`

public class TrapException extends JdbcInterceptor
Interceptor that traps any unhandled exception types and throws an exception that has been declared by the method called, or throw an SQLException if it is declared. If the caught exception is not declared, and the method doesn't throw SQLException, then this interceptor will throw a RuntimeException

- ## Field Summary

  ### Fields inherited from class JdbcInterceptor

  `CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TrapException()`
  Constructs a new TrapException interceptor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `invoke(Object proxy, Method method, Object[] args)`
  Gets invoked each time an operation on `Connection` is invoked.
  `boolean`
  `isDeclaredException(Method m, Class<?> clazz)`
  Checks if the given exception class is declared in the throws clause of the specified method.
  `void`
  `reset(ConnectionPool parent, PooledConnection con)`
  no-op for this interceptor. no state is stored.

  ### Methods inherited from class JdbcInterceptor

  `compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TrapException

    public TrapException()
    Constructs a new TrapException interceptor.

- ## Method Details

  - ### invoke

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    Description copied from class: `JdbcInterceptor`
    Gets invoked each time an operation on `Connection` is invoked.
    Specified by:
      `invoke` in interface `InvocationHandler`
    Overrides:
      `invoke` in class `JdbcInterceptor`
    Throws:
      `Throwable`

  - ### isDeclaredException

    public boolean isDeclaredException(Method m, Class<?> clazz)
    Checks if the given exception class is declared in the throws clause of the specified method.
    Parameters:
      `m` - The method to check
      `clazz` - The exception class to look for
    Returns:
      `true` if the exception is declared, `false` otherwise

  - ### reset

    public void reset(ConnectionPool parent, PooledConnection con)
    no-op for this interceptor. no state is stored.
    Specified by:
      `reset` in class `JdbcInterceptor`
    Parameters:
      `parent` - - the connection pool owning the connection
      `con` - - the pooled connection