Exception: VagrantCloud::Error::ClientError::RequestError
- Inherits:
-
VagrantCloud::Error::ClientError
- Object
- StandardError
- VagrantCloud::Error
- VagrantCloud::Error::ClientError
- VagrantCloud::Error::ClientError::RequestError
- Defined in:
- lib/vagrant_cloud/error.rb
Instance Attribute Summary collapse
-
#error_arr ⇒ Object
Returns the value of attribute error_arr.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
Instance Method Summary collapse
-
#initialize(msg, http_body, http_code) ⇒ RequestError
constructor
A new instance of RequestError.
Constructor Details
#initialize(msg, http_body, http_code) ⇒ RequestError
Returns a new instance of RequestError.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant_cloud/error.rb', line 8 def initialize(msg, http_body, http_code) = msg begin errors = JSON.parse(http_body) if errors.is_a?(Hash) vagrant_cloud_msg = errors['errors'] if vagrant_cloud_msg.is_a?(Array) = msg + ' - ' + vagrant_cloud_msg.map(&:to_s).join(', ').to_s elsif !vagrant_cloud_msg.to_s.empty? = msg + ' - ' + vagrant_cloud_msg.to_s end end rescue JSON::ParserError => err vagrant_cloud_msg = err. end @error_arr = Array(vagrant_cloud_msg) @error_code = http_code.to_i super() end |
Instance Attribute Details
#error_arr ⇒ Object
Returns the value of attribute error_arr.
6 7 8 |
# File 'lib/vagrant_cloud/error.rb', line 6 def error_arr @error_arr end |
#error_code ⇒ Object
Returns the value of attribute error_code.
5 6 7 |
# File 'lib/vagrant_cloud/error.rb', line 5 def error_code @error_code end |