summaryrefslogtreecommitdiff
path: root/core/lib/extensions
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-03-14 12:57:57 +0100
committerAzul <azul@leap.se>2013-03-14 17:36:10 +0100
commitd1449a6563cb53d415c107db2025ef2de5265644 (patch)
treea95cd7b728c4ddc81bcbeda91cc367ec3bff74bb /core/lib/extensions
parent869ba2f363a48d0f76321efc08a228f54aeb6758 (diff)
catch Errno's and RestClient errors and throw a more meaningful couchrest error
Diffstat (limited to 'core/lib/extensions')
-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 57bb837..f203426 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