Class ExceptionUtil


  • public class ExceptionUtil
    extends java.lang.Object
    Author:
    Roman Smirnov, Askar Akhmerov
    • Field Detail

      • PERSISTENCE_EXCEPTION_MESSAGE

        public static final java.lang.String PERSISTENCE_EXCEPTION_MESSAGE
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExceptionUtil

        public ExceptionUtil()
    • Method Detail

      • getExceptionStacktrace

        public static java.lang.String getExceptionStacktrace​(java.lang.Throwable exception)
      • getExceptionStacktrace

        public static java.lang.String getExceptionStacktrace​(ByteArrayEntity byteArray)
      • createExceptionByteArray

        public static ByteArrayEntity createExceptionByteArray​(java.lang.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 exception
        byteArray - - payload of the exception
        type - - resource type of the exception
        Returns:
        persisted entity
      • getPersistenceCauseException

        protected static java.lang.Throwable getPersistenceCauseException​(org.apache.ibatis.exceptions.PersistenceException persistenceException)
      • unwrapException

        public static java.sql.SQLException unwrapException​(org.apache.ibatis.exceptions.PersistenceException persistenceException)
      • unwrapException

        public static java.sql.SQLException unwrapException​(ProcessEngineException genericPersistenceException)
      • checkValueTooLongException

        public static boolean checkValueTooLongException​(java.sql.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)
      • checkForeignKeyConstraintViolation

        public static boolean checkForeignKeyConstraintViolation​(java.sql.SQLException sqlException)
      • checkVariableIntegrityViolation

        public static boolean checkVariableIntegrityViolation​(org.apache.ibatis.exceptions.PersistenceException persistenceException)
      • checkCrdbTransactionRetryException

        public static boolean checkCrdbTransactionRetryException​(java.lang.Throwable exception)
      • checkCrdbTransactionRetryException

        public static boolean checkCrdbTransactionRetryException​(java.sql.SQLException sqlException)
      • checkDeadlockException

        public static boolean checkDeadlockException​(java.sql.SQLException sqlException)
      • findBatchExecutorException

        public static org.apache.ibatis.executor.BatchExecutorException findBatchExecutorException​(org.apache.ibatis.exceptions.PersistenceException exception)
      • doWithExceptionWrapper

        public static <T> T doWithExceptionWrapper​(java.util.function.Supplier<T> supplier)
        Pass logic, which directly calls MyBatis API. In case a MyBatis exception is thrown, it is wrapped into a ProcessEngineException 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 a ProcessEngineException 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​(java.lang.Exception ex)