summaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-04-08 11:17:47 -0700
committerjessib <jessib@riseup.net>2013-04-08 11:17:47 -0700
commit45c59e825a36be48d86518b5f26ae279e8a2d301 (patch)
tree6e2554e147d188cb7fc13c51295fe2e7ba185f6f /core/lib
parent176845b45f6982b0bf26aa69e7432562eed97c69 (diff)
parentd1449a6563cb53d415c107db2025ef2de5265644 (diff)
Merge pull request #38 from azul/feature/meainingful_couch_error
catch Errno's and RestClient errors and throw a more meaningful error
Diffstat (limited to 'core/lib')
-rw-r--r--core/lib/extensions/couchrest.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb
index b17159b..176184f 100644
--- a/core/lib/extensions/couchrest.rb
+++ b/core/lib/extensions/couchrest.rb
@@ -23,6 +23,25 @@ module CouchRest
end
end
+ module Errors
+ class ConnectionFailed < CouchRestModelError; end
+ end
+
+ module Connection
+
+ module ClassMethods
+
+ def use_database(db)
+ @database = prepare_database(db)
+ rescue RestClient::Unauthorized,
+ Errno::EHOSTUNREACH,
+ Errno::ECONNREFUSED => e
+ raise CouchRest::Model::Errors::ConnectionFailed.new(e.to_s)
+ end
+ end
+
+ end
+
class Migrate
def self.load_all_models_with_engines
self.load_all_models_without_engines