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.
57 58 59 60 |
# File 'lib/gcloud/pubsub/errors.rb', line 57 def initialize , response super @response = response end |
Class Method Details
.from_response(resp) ⇒ Object
:nodoc:
62 63 64 65 66 67 |
# File 'lib/gcloud/pubsub/errors.rb', line 62 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
69 70 71 72 73 74 75 76 |
# File 'lib/gcloud/pubsub/errors.rb', line 69 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.
43 44 45 46 47 |
# File 'lib/gcloud/pubsub/errors.rb', line 43 def code response.data["error"]["code"] rescue nil end |
#errors ⇒ Object
The errors encountered.
51 52 53 54 55 |
# File 'lib/gcloud/pubsub/errors.rb', line 51 def errors response.data["error"]["errors"] rescue [] end |