Exception: Gcloud::Vision::ApiError
- Defined in:
- lib/gcloud/vision/errors.rb
Overview
# ApiError
Raised when an API call is not successful.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
The HTTP code of the error.
-
#errors ⇒ Object
readonly
The errors encountered.
-
#status ⇒ Object
readonly
The Google API error status.
Attributes inherited from Error
Attributes inherited from Error
Class Method Summary collapse
Methods inherited from Error
from_error, #initialize, klass_for
Constructor Details
This class inherits a constructor from Gcloud::Error
Instance Attribute Details
#code ⇒ Object (readonly)
The HTTP code of the error.
44 45 46 |
# File 'lib/gcloud/vision/errors.rb', line 44 def code @code end |
#errors ⇒ Object (readonly)
The errors encountered.
52 53 54 |
# File 'lib/gcloud/vision/errors.rb', line 52 def errors @errors end |
#status ⇒ Object (readonly)
The Google API error status.
48 49 50 |
# File 'lib/gcloud/vision/errors.rb', line 48 def status @status end |
Class Method Details
.from_response(resp) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gcloud/vision/errors.rb', line 55 def self.from_response resp if resp.data? && resp.data["error"] new(resp.data["error"]["message"]).tap do |e| e.instance_variable_set "@code", resp.data["error"]["code"] e.instance_variable_set "@status", resp.data["error"]["status"] e.instance_variable_set "@errors", resp.data["error"]["errors"] e.instance_variable_set "@response", resp end else Error.from_response_status resp end end |