Module: MockRedis::Error

Defined in:
lib/mock_redis/error.rb

Class Method Summary collapse

Class Method Details

.build(error_class, message, database) ⇒ Object



5
6
7
8
9
# File 'lib/mock_redis/error.rb', line 5

def build(error_class, message, database)
  connection = database.connection
  url = "redis://#{connection[:host]}:#{connection[:port]}"
  error_class.new("#{message} (#{url})")
end

.command_error(message, database) ⇒ Object



23
24
25
# File 'lib/mock_redis/error.rb', line 23

def command_error(message, database)
  build(Redis::CommandError, message, database)
end

.syntax_error(database) ⇒ Object



19
20
21
# File 'lib/mock_redis/error.rb', line 19

def syntax_error(database)
  command_error('ERR syntax error', database)
end

.wrong_type_error(database) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/mock_redis/error.rb', line 11

def wrong_type_error(database)
  build(
    Redis::WrongTypeError,
    'WRONGTYPE Operation against a key holding the wrong kind of value',
    database
  )
end