summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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