Class: RedisClient::CommandError

Inherits:
Error
  • Object
show all
Includes:
HasCommand
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb

Constant Summary collapse

ERRORS =
{
  "WRONGPASS" => AuthenticationError,
  "NOPERM" => PermissionError,
  "READONLY" => ReadOnlyError,
  "MASTERDOWN" => MasterDownError,
  "WRONGTYPE" => WrongTypeError,
  "OOM" => OutOfMemoryError,
}.freeze

Instance Attribute Summary

Attributes included from HasCommand

#command

Class Method Summary collapse

Methods included from HasCommand

#_set_command

Class Method Details

.parse(error_message) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 105

def parse(error_message)
  code = if error_message.start_with?("ERR Error running script")
    # On older redis servers script errors are nested.
    # So we need to parse some more.
    if (match = error_message.match(/:\s-([A-Z]+) /))
      match[1]
    end
  end
  code ||= error_message.split(' ', 2).first
  klass = ERRORS.fetch(code, self)
  klass.new(error_message)
end