Permalink
Browse files

catch -> log

  • Loading branch information...
1 parent 7716b8e commit 26a57e587a7b7ff0db518cb327957b507276918e Ezra Zygmuntowicz committed Mar 11, 2009
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/nanite/state.rb
View
@@ -29,15 +29,15 @@ def initialize
@redis = Redis.new
end
- def catch_redis_error(meth,&blk)
+ def log_redis_error(meth,&blk)
blk.call
rescue RedisError => e
Nanite::Log.info("redis error in method: #{meth}")
raise e
end
def [](nanite)
- catch_redis_error("[]") do
+ log_redis_error("[]") do
status = @redis[nanite]
timestamp = @redis["t-#{nanite}"]
services = @redis.set_members("s-#{nanite}")
@@ -47,13 +47,13 @@ def [](nanite)
end
def []=(nanite, hsh)
- catch_redis_error("[]=") do
+ log_redis_error("[]=") do
update_state(nanite, hsh[:status], hsh[:services])
end
end
def delete(nanite)
- catch_redis_error("delete") do
+ log_redis_error("delete") do
redis.set_members("s-#{nanite}").each do |srv|
@redis.set_delete(s, nanite)
end
@@ -64,7 +64,7 @@ def delete(nanite)
end
def all_services
- catch_redis_error("all_services") do
+ log_redis_error("all_services") do
@redis.set_members("nanite-services")
end
end
@@ -86,13 +86,13 @@ def update_state(name, status, services)
end
def list_nanites
- catch_redis_error("list_nanites") do
+ log_redis_error("list_nanites") do
@redis.keys("nanite-*")
end
end
def clear_state
- catch_redis_error("clear_state") do
+ log_redis_error("clear_state") do
@redis.keys("*").each {|k| @redis.delete k}
end
end
@@ -104,7 +104,7 @@ def each
end
def nanites_for(*srvs)
- catch_redis_error("nanites_for") do
+ log_redis_error("nanites_for") do
res = []
@redis.set_intersect(srvs).each do |nan|
res << [nan, self[nan]]

0 comments on commit 26a57e5

Please sign in to comment.