Sha256: 45f205c81af12dc35a21c949fc8f50f7703c17a056cdaba1094e0add417d94c2

Contents?: true

Size: 616 Bytes

Versions: 7

Compression:

Stored size: 616 Bytes

Contents

module VagrantCloud
  class ClientError < StandardError
    attr_accessor :error_arr
    attr_accessor :error_code

    def initialize(msg, http_body, http_code)
      begin
        errors = JSON.parse(http_body)
        vagrant_cloud_msg = errors['errors']

        if vagrant_cloud_msg.is_a?(Array)
          message = msg + ' - ' + vagrant_cloud_msg.join(', ').to_s
        else
          message = msg + ' - ' + vagrant_cloud_msg
        end
      rescue JSON::ParserError
        message = msg
      end

      @error_arr = vagrant_cloud_msg
      @error_code = http_code
      super(message)
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/vagrant_cloud-2.0.1/lib/vagrant_cloud/errors.rb
vagrant_cloud-2.0.1 lib/vagrant_cloud/errors.rb
vagrant_cloud-2.0.0 lib/vagrant_cloud/errors.rb