def handle(msg, fexp, err)

      err = RaisedError.new(err) unless err.respond_to?(:backtrace)

      meta = err.is_a?(Ruote::MetaError)

      fei = msg['fei'] || (fexp.h.fei rescue nil)
      wfid = msg['wfid'] || (fei || {})['wfid']

      # on_error ?

      return if ( ! meta) && fexp && fexp.handle_on_error(msg, err)

      # emit 'msg'
      #
      # (this message might get intercepted by a tracker)

      herr = deflate(err, fei, fexp)

      # fill error in the error journal

      @context.storage.put(
        herr.merge(
          'type' => 'errors',
          '_id' => "err_#{Ruote.to_storage_id(fei)}",
          'message' => err.inspect,                     # :-(
          'trace' => (err.backtrace || []).join("\n"),  # :-(
          'msg' => msg)
      ) if fei

      # advertise 'error_intercepted'

      @context.storage.put_msg(
        'error_intercepted',
        'error' => herr, 'wfid' => wfid, 'fei' => fei, 'msg' => msg)

    rescue => e

      raise e unless @context.worker

      @context.worker.send(
        :handle_step_error,
        e,
        { 'action' => 'error_intercepted',
          'error' => deflate(err, fei),
          'fei' => fei,
          'wfid' => wfid,
          'msg' => msg })
    end
def handle(msg, fexp, err)

      err = RaisedError.new(err) unless err.respond_to?(:backtrace)

      meta = err.is_a?(Ruote::MetaError)

      fei = msg['fei'] || (fexp.h.fei rescue nil)
      wfid = msg['wfid'] || (fei || {})['wfid']

      # on_error ?

      return if ( ! meta) && fexp && fexp.handle_on_error(msg, err)

      # emit 'msg'
      #
      # (this message might get intercepted by a tracker)

      herr = deflate(err, fei, fexp)

      # fill error in the error journal

      @context.storage.put(
        herr.merge(
          'type' => 'errors',
          '_id' => "err_#{Ruote.to_storage_id(fei)}",
          'message' => err.inspect,                     # :-(
          'trace' => (err.backtrace || []).join("\n"),  # :-(
          'msg' => msg)
      ) if fei

      # advertise 'error_intercepted'

      @context.storage.put_msg(
        'error_intercepted',
        'error' => herr, 'wfid' => wfid, 'fei' => fei, 'msg' => msg)

    rescue => e

      raise e unless @context.worker

      @context.worker.send(
        :handle_step_error,
        e,
        { 'action' => 'error_intercepted',
          'error' => deflate(err, fei),
          'fei' => fei,
          'wfid' => wfid,
          'msg' => msg })
    end
Called by msg_handle or action_handle.