Package io.jmix.uidata.exception
Class UniqueConstraintViolationHandler
java.lang.Object
io.jmix.uidata.exception.UniqueConstraintViolationHandler
- All Implemented Interfaces:
UiExceptionHandler
,org.springframework.core.Ordered
@Component("ui_UniqueConstraintViolationHandler")
public class UniqueConstraintViolationHandler
extends Object
implements UiExceptionHandler, org.springframework.core.Ordered
Handles database unique constraint violations. Determines the exception type by searching a special marker string
in the messages of all exceptions in the chain.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.exception.UiExceptionHandler
UiExceptionHandler.UiContext
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected Messages
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
doHandle
(UniqueConstraintViolationException exception, UiExceptionHandler.UiContext context) protected String
getDefaultMessage
(String constraintName) protected String
getMessage
(String constraintName) int
getOrder()
boolean
handle
(Throwable exception, UiExceptionHandler.UiContext context) Handle an exception.
-
Field Details
-
DEFAULT_MESSAGE_PROPERTY
- See Also:
-
MESSAGE_PREFIX
- See Also:
-
messages
-
-
Constructor Details
-
UniqueConstraintViolationHandler
public UniqueConstraintViolationHandler()
-
-
Method Details
-
handle
Description copied from interface:UiExceptionHandler
Handle an exception. Implementation class should either handle the exception and return true, or return false to delegate execution to the next handler in the chain of responsibility.- Specified by:
handle
in interfaceUiExceptionHandler
- Parameters:
exception
- exception instancecontext
- UI context- Returns:
- true if the exception has been successfully handled, false if not
-
doHandle
protected boolean doHandle(UniqueConstraintViolationException exception, UiExceptionHandler.UiContext context) -
getMessage
-
getDefaultMessage
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-