Method: Faulty::Patch::Redis#io

Defined in:
lib/faulty/patch/redis/patch.rb

#io(&block) ⇒ Object

Inject specific error classes if client is patched

This method does not raise errors, it returns them as exception objects, so we simply modify that error if necessary and return it.

The call* methods above will then raise that error, so we are able to capture it with faulty_run.



58
59
60
61
62
63
64
65
66
67
# File 'lib/faulty/patch/redis/patch.rb', line 58

def io(&block)
  return super unless @faulty_circuit

  reply = super
  if reply.is_a?(::Redis::CommandError) && reply.message.start_with?('BUSY')
    reply = BusyError.new(reply.message)
  end

  reply
end