]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/aviator/lib/puppet/feature/faraday/error.rb
Revert "add stackforge/keystone to 3rdparty"
[dsa-puppet.git] / 3rdparty / modules / aviator / lib / puppet / feature / faraday / error.rb
1 module Faraday
2   class Error < StandardError; end
3   class MissingDependency < Error; end
4
5   class ClientError < Error
6     attr_reader :response
7
8     def initialize(ex, response = nil)
9       @wrapped_exception = nil
10       @response = response
11
12       if ex.respond_to?(:backtrace)
13         super(ex.message)
14         @wrapped_exception = ex
15       elsif ex.respond_to?(:each_key)
16         super("the server responded with status #{ex[:status]}")
17         @response = ex
18       else
19         super(ex.to_s)
20       end
21     end
22
23     def backtrace
24       if @wrapped_exception
25         @wrapped_exception.backtrace
26       else
27         super
28       end
29     end
30
31     def inspect
32       %(#<#{self.class}>)
33     end
34   end
35
36   class ConnectionFailed < ClientError;   end
37   class ResourceNotFound < ClientError;   end
38   class ParsingError     < ClientError;   end
39
40   class TimeoutError < ClientError
41     def initialize(ex = nil)
42       super(ex || "timeout")
43     end
44   end
45
46   class SSLError < ClientError
47   end
48
49   [:MissingDependency, :ClientError, :ConnectionFailed, :ResourceNotFound,
50    :ParsingError, :TimeoutError, :SSLError].each do |const|
51     Error.const_set(const, Faraday.const_get(const))
52   end
53 end