Exception: Gcloud::Dns::ApiError
- Defined in:
- lib/gcloud/dns/errors.rb
Overview
Raised when an API call is not successful.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
The code of the error.
-
#errors ⇒ Object
readonly
The errors encountered.
Attributes inherited from Error
Class Method Summary collapse
- .from_response(resp) ⇒ Object
- .from_response_data(error) ⇒ Object
- .from_response_status(resp) ⇒ Object
Instance Method Summary collapse
-
#initialize(message, code, errors = []) ⇒ ApiError
constructor
A new instance of ApiError.
Methods inherited from Error
Constructor Details
#initialize(message, code, errors = []) ⇒ ApiError
Returns a new instance of ApiError.
37 38 39 40 41 |
# File 'lib/gcloud/dns/errors.rb', line 37 def initialize , code, errors = [] super @code = code @errors = errors end |
Instance Attribute Details
#code ⇒ Object (readonly)
The code of the error.
30 31 32 |
# File 'lib/gcloud/dns/errors.rb', line 30 def code @code end |
#errors ⇒ Object (readonly)
The errors encountered.
34 35 36 |
# File 'lib/gcloud/dns/errors.rb', line 34 def errors @errors end |
Class Method Details
.from_response(resp) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/gcloud/dns/errors.rb', line 44 def self.from_response resp if resp.data? && resp.data["error"] from_response_data resp.data["error"] else from_response_status resp end end |
.from_response_data(error) ⇒ Object
53 54 55 |
# File 'lib/gcloud/dns/errors.rb', line 53 def self.from_response_data error new error["message"], error["code"], error["errors"] end |
.from_response_status(resp) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/gcloud/dns/errors.rb', line 58 def self.from_response_status resp if resp.status == 404 new "#{resp.}: #{resp.request.uri.request_uri}", resp.status else new resp., resp.status end end |