- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The default mapper throws a PersistenceException as it is and wraps any other failure in one. 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) and classifies it before invoking the mapper: a deadlock or a serialization
failure arrives as a TransientPersistenceException and a write the database refused for a constraint as an
IntegrityViolationException, each with the driver's exception as its cause. The mapper only decides the
exception type that is thrown.
The failures Storm's own logic detects after a statement ran pass through the mapper as well: an optimistic lock conflict, a single result that is missing or not unique, a write that affected no row. Their context names the operation and, for a write, the entity type, but no statement. A mapper that translates to a platform hierarchy translates them too, so a caller sees one exception family whichever side detected the failure.
- Since:
- 1.13
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExceptionMapperReturns the default exception mapper.map(Throwable cause, ExceptionContext context) Maps the given failure to the runtime exception that is thrown to the caller.
-
Method Details
-
map
Maps the given failure to the runtime exception that is thrown to the caller.- Parameters:
cause- the failure; typically aPersistenceException, or aSQLExceptionthe framework could not classify. The framework has already attached SQL diagnostics as a suppressed exception where available.context- the execution context of the failure; nevernull.- Returns:
- the exception to throw; never
null.
-
defaultMapper
Returns the default exception mapper.The default mapper passes a
PersistenceExceptionthrough unchanged and wraps any other failure in a newPersistenceException.- Returns:
- the default exception mapper.
-