Package st.orm.spi

Interface ExceptionMapper

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ExceptionMapper
Maps failures raised during query execution to the runtime exception thrown to the caller.

The default mapper wraps failures in PersistenceException. Integrations may translate to platform exception hierarchies instead, such as Spring's DataAccessException.

Exception mappers are configured per ORM template via the template builder; they are deliberately not discovered through the ServiceLoader mechanism. The framework enriches the failure with SQL diagnostics (as a suppressed exception on the cause) before invoking the mapper, so the mapper only decides the exception type that is thrown.

Since:
1.13
See Also:
  • Method Details

    • map

      Maps the given failure to the runtime exception that is thrown to the caller.
      Parameters:
      cause - the failure; typically a SQLException or PersistenceException. The framework has already attached SQL diagnostics as a suppressed exception where available.
      context - the execution context of the failure; never null.
      Returns:
      the exception to throw; never null.
    • defaultMapper

      static ExceptionMapper defaultMapper()
      Returns the default exception mapper.

      The default mapper passes PersistenceException instances through unchanged and wraps any other failure in a new PersistenceException.

      Returns:
      the default exception mapper.