/// <param name="type">
        ///          type of event </param>
        /// <param name="entity">
        ///          the entity this event targets </param>
        /// <param name="cause">
        ///          the cause of the event </param>
        /// <returns> an <seealso cref="IActivitiEntityEvent"/> that is also instance of <seealso cref="IActivitiExceptionEvent"/>. In case an <seealso cref="ExecutionContext"/> is active, the execution related event fields will be
        ///         populated. </returns>
        public static IActivitiEntityEvent CreateEntityExceptionEvent(ActivitiEventType type, object entity, Exception cause)
        {
            ActivitiEntityExceptionEventImpl newEvent = new ActivitiEntityExceptionEventImpl(entity, type, cause);

            // In case an execution-context is active, populate the event fields
            // related to the execution
            PopulateEventWithCurrentContext(newEvent);
            return(newEvent);
        }
        /// <param name="type">
        ///          type of event </param>
        /// <param name="entity">
        ///          the entity this event targets </param>
        /// <param name="cause">
        ///          the cause of the event </param>
        /// <returns> an <seealso cref="IActivitiEntityEvent"/> that is also instance of <seealso cref="IActivitiExceptionEvent"/>. </returns>
        public static IActivitiEntityEvent CreateEntityExceptionEvent(ActivitiEventType type, object entity, Exception cause, string executionId, string processInstanceId, string processDefinitionId)
        {
            ActivitiEntityExceptionEventImpl newEvent = new ActivitiEntityExceptionEventImpl(entity, type, cause)
            {
                ExecutionId         = executionId,
                ProcessInstanceId   = processInstanceId,
                ProcessDefinitionId = processDefinitionId
            };

            return(newEvent);
        }