       @getDomainEventsStore().saveDomainEvent domainEvent
       .then =>
         @getEventBus().publishDomainEvent domainEvent
-        .catch (error) =>
+        .catch (error = {}) =>
           @_eventric.log.error error.stack || error
         resolve domainEvent
       .catch reject
 
-    @_addPendingOperation emittingDomainEvent
+    @_addPendingPromise emittingDomainEvent
 
     return emittingDomainEvent
 

    repositoriesCache[aggregateName]


  _addPendingOperation: (pendingOperation) ->
    errorSuppressedPendingOperation = pendingOperation.catch ->
    @_pendingOperations.push errorSuppressedPendingOperation
    errorSuppressedPendingOperation.then =>
      @_pendingOperations.splice @_pendingOperations.indexOf(errorSuppressedPendingOperation), 1


  query: (queryName, params) ->

        err = new Error err
        return reject err

      Promise.resolve @_queryHandlers[queryName].apply @_di, [params]
      .then (result) =>
        @log.debug "Completed Query #{queryName} with Result #{result}"
        resolve result
      .catch reject


  _verifyContextIsInitialized: (methodName) ->
