Package org.camunda.bpm.engine.impl.util
Class ExceptionUtil
- java.lang.Object
-
- org.camunda.bpm.engine.impl.util.ExceptionUtil
-
public class ExceptionUtil extends Object
- Author:
- Roman Smirnov, Askar Akhmerov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExceptionUtil.DEADLOCK_CODES
-
Field Summary
Fields Modifier and Type Field Description static String
PERSISTENCE_EXCEPTION_MESSAGE
-
Constructor Summary
Constructors Constructor Description ExceptionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkConstraintViolationException(ProcessEngineException genericPersistenceException)
static boolean
checkCrdbTransactionRetryException(Throwable exception)
static boolean
checkCrdbTransactionRetryException(SQLException sqlException)
static boolean
checkDeadlockException(SQLException sqlException)
static boolean
checkForeignKeyConstraintViolation(SQLException sqlException, boolean skipPostgres)
static boolean
checkForeignKeyConstraintViolation(org.apache.ibatis.exceptions.PersistenceException persistenceException, boolean skipPostgres)
static boolean
checkValueTooLongException(SQLException sqlException)
static boolean
checkValueTooLongException(ProcessEngineException genericPersistenceException)
static boolean
checkVariableIntegrityViolation(org.apache.ibatis.exceptions.PersistenceException persistenceException)
static ByteArrayEntity
createExceptionByteArray(String name, byte[] byteArray, ResourceType type)
create ByteArrayEntity with specified name and payload and make sure it's persisted used in Jobs and ExternalTasksstatic ByteArrayEntity
createJobExceptionByteArray(byte[] byteArray, ResourceType type)
static <T> T
doWithExceptionWrapper(Supplier<T> supplier)
Pass logic, which directly calls MyBatis API.static org.apache.ibatis.executor.BatchExecutorException
findBatchExecutorException(org.apache.ibatis.exceptions.PersistenceException exception)
static String
getExceptionStacktrace(Throwable exception)
static String
getExceptionStacktrace(ByteArrayEntity byteArray)
protected static Throwable
getPersistenceCauseException(org.apache.ibatis.exceptions.PersistenceException persistenceException)
static SQLException
unwrapException(org.apache.ibatis.exceptions.PersistenceException persistenceException)
static SQLException
unwrapException(ProcessEngineException genericPersistenceException)
static ProcessEngineException
wrapPersistenceException(Exception ex)
-
-
-
Field Detail
-
PERSISTENCE_EXCEPTION_MESSAGE
public static final String PERSISTENCE_EXCEPTION_MESSAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getExceptionStacktrace
public static String getExceptionStacktrace(ByteArrayEntity byteArray)
-
createJobExceptionByteArray
public static ByteArrayEntity createJobExceptionByteArray(byte[] byteArray, ResourceType type)
-
createExceptionByteArray
public static ByteArrayEntity createExceptionByteArray(String name, byte[] byteArray, ResourceType type)
create ByteArrayEntity with specified name and payload and make sure it's persisted used in Jobs and ExternalTasks- Parameters:
name
- - type\source of the exceptionbyteArray
- - payload of the exceptiontype
- - resource type of the exception- Returns:
- persisted entity
-
getPersistenceCauseException
protected static Throwable getPersistenceCauseException(org.apache.ibatis.exceptions.PersistenceException persistenceException)
-
unwrapException
public static SQLException unwrapException(org.apache.ibatis.exceptions.PersistenceException persistenceException)
-
unwrapException
public static SQLException unwrapException(ProcessEngineException genericPersistenceException)
-
checkValueTooLongException
public static boolean checkValueTooLongException(SQLException sqlException)
-
checkValueTooLongException
public static boolean checkValueTooLongException(ProcessEngineException genericPersistenceException)
-
checkConstraintViolationException
public static boolean checkConstraintViolationException(ProcessEngineException genericPersistenceException)
-
checkForeignKeyConstraintViolation
public static boolean checkForeignKeyConstraintViolation(org.apache.ibatis.exceptions.PersistenceException persistenceException, boolean skipPostgres)
-
checkForeignKeyConstraintViolation
public static boolean checkForeignKeyConstraintViolation(SQLException sqlException, boolean skipPostgres)
-
checkVariableIntegrityViolation
public static boolean checkVariableIntegrityViolation(org.apache.ibatis.exceptions.PersistenceException persistenceException)
-
checkCrdbTransactionRetryException
public static boolean checkCrdbTransactionRetryException(Throwable exception)
-
checkCrdbTransactionRetryException
public static boolean checkCrdbTransactionRetryException(SQLException sqlException)
-
checkDeadlockException
public static boolean checkDeadlockException(SQLException sqlException)
-
findBatchExecutorException
public static org.apache.ibatis.executor.BatchExecutorException findBatchExecutorException(org.apache.ibatis.exceptions.PersistenceException exception)
-
doWithExceptionWrapper
public static <T> T doWithExceptionWrapper(Supplier<T> supplier)
Pass logic, which directly calls MyBatis API. In case a MyBatis exception is thrown, it is wrapped into aProcessEngineException
and never propagated directly to an Engine API call. In some cases, the top-level exception and its message are shown as a response body in the REST API. Wrapping all MyBatis API calls in our codebase makes sure that the top-level exception is always aProcessEngineException
with a generic message. Like this, SQL details are never disclosed to potential attackers.- Type Parameters:
T
- is the type of the return value- Parameters:
supplier
- which calls MyBatis API- Returns:
- the value returned by the supplier
- Throws:
ProcessEngineException
- which wraps the actual exception
-
wrapPersistenceException
public static ProcessEngineException wrapPersistenceException(Exception ex)
-
-