Permalink
Browse files

Change on_error to errback. errback is the standard way to hook error…

…s, also it already was there from EM::Deferrable.
  • Loading branch information...
1 parent 4bc1d98 commit ba62188926510b35b4722fc6edee32fc634b2401 @libc libc committed Feb 5, 2010
Showing with 9 additions and 10 deletions.
  1. +9 −10 lib/em-redis/redis_protocol.rb
@@ -219,9 +219,10 @@ def quit(&blk)
call_command(['quit'], &blk)
end
- def on_error(&blk)
- @err_cb = blk
+ def errback(&blk)
+ @error_callback = blk
end
+ alias_method :on_error, :errback
def method_missing(*argv, &blk)
call_command(argv, &blk)
@@ -308,6 +309,11 @@ def initialize(options = {})
@db = (options[:db] || 0).to_i
@password = options[:password]
@logger = options[:logger]
+ @error_callback = lambda do |code|
+ err = RedisError.new
+ err.code = code
+ raise err, "Redis server returned error code: #{code}"
+ end
end
def connection_completed
@@ -350,14 +356,7 @@ def process_cmd(line)
#e.g. -MISSING
when MINUS
@redis_callbacks.shift # throw away the cb?
- if @err_cb
- @err_cb.call(reply_args)
- else
- err = RedisError.new
- err.code = reply_args
- raise err, "Redis server returned error code: #{err.code}"
- end
-
+ @error_callback.call(reply_args)
# e.g. +OK
when PLUS
dispatch_response(reply_args)

0 comments on commit ba62188

Please sign in to comment.