Exception: Gcloud::Pubsub::ApiError
- Defined in:
- lib/gcloud/pubsub/errors.rb
Overview
ApiError
Raised when an API call is not successful.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Error
Class Method Summary collapse
Instance Method Summary collapse
-
#code ⇒ Object
The code of the error.
-
#errors ⇒ Object
The errors encountered.
-
#initialize(message, response) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(message, response) ⇒ ApiError
Returns a new instance of ApiError.
55 56 57 58 |
# File 'lib/gcloud/pubsub/errors.rb', line 55 def initialize , response super @response = response end |
Class Method Details
.from_response(resp) ⇒ Object
:nodoc:
60 61 62 63 64 65 |
# File 'lib/gcloud/pubsub/errors.rb', line 60 def self.from_response resp #:nodoc: klass = klass_for resp.data["error"]["status"] klass.new resp.data["error"]["message"], resp rescue Gcloud::Pubsub::Error.from_response resp end |
.klass_for(status) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/gcloud/pubsub/errors.rb', line 67 def self.klass_for status if status == "ALREADY_EXISTS" return AlreadyExistsError elsif status == "NOT_FOUND" return NotFoundError end self end |
Instance Method Details
#code ⇒ Object
The code of the error.
41 42 43 44 45 |
# File 'lib/gcloud/pubsub/errors.rb', line 41 def code response.data["error"]["code"] rescue nil end |
#errors ⇒ Object
The errors encountered.
49 50 51 52 53 |
# File 'lib/gcloud/pubsub/errors.rb', line 49 def errors response.data["error"]["errors"] rescue [] end |