diff options
author | Marc Fournier <marc.fournier@camptocamp.com> | 2012-10-23 23:34:39 -0700 |
---|---|---|
committer | Marc Fournier <marc.fournier@camptocamp.com> | 2012-10-23 23:34:39 -0700 |
commit | ec4102284592b74376f36660bf0f888fb5efe4da (patch) | |
tree | 7d292054505af595b0a5d58f2510201c4e5cfdd7 /lib/puppet/parser/functions | |
parent | e97e408116525f28b53162b89e6b582fb71020d2 (diff) | |
parent | 03bd5b2244f9fa5e8a3de40a3678652d2a26f097 (diff) |
Merge pull request #5 from mfournier/improve-couchdb-error-handling
couchdblookup: improved error handling
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r-- | lib/puppet/parser/functions/couchdblookup.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/couchdblookup.rb b/lib/puppet/parser/functions/couchdblookup.rb index 132c488..b9067d2 100644 --- a/lib/puppet/parser/functions/couchdblookup.rb +++ b/lib/puppet/parser/functions/couchdblookup.rb @@ -16,8 +16,16 @@ module Puppet::Parser::Functions begin json = JSON.parse(open(URI.parse(url)).read) - rescue OpenURI::HTTPError, JSON::ParserError => error - raise Puppet::ParseError, "couchdblookup(): fetching URL #{url} failed with status #{error.message}" + rescue OpenURI::HTTPError => error + raise Puppet::ParseError, "couchdblookup(): fetching URL #{url} failed with status '#{error.message}'" + rescue Timeout::Error => error + raise Puppet::ParseError, "couchdblookup(): connection to couchdb server timed out: '#{error.message}'" + rescue Errno::ECONNREFUSED => error + raise Puppet::ParseError, "couchdblookup(): connection to couchdb server failed: '#{error.message}'" + rescue JSON::ParserError => error + raise Puppet::ParseError, "couchdblookup(): failed to parse JSON received from couchdb: '#{error.message}'" + rescue StandardError => error + raise Puppet::ParseError, "couchdblookup(): something unexpected happened: '#{error.inspect}'" end result = nil |