Sha256: 56a846750a5d436b148b7a69c9baa82616b2cd94dfda67d292e912f9be616562

Contents?: true

Size: 948 Bytes

Versions: 2

Compression:

Stored size: 948 Bytes

Contents

=begin
# Mux Ruby - Copyright 2019 Mux Inc.
# NOTE: This file is auto generated. Do not edit this file manually.
=end

module MuxRuby
  class ApiError < StandardError
    attr_reader :code, :response_headers, :response_body

    # Usage examples:
    #   ApiError.new
    #   ApiError.new("message")
    #   ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
    #   ApiError.new(:code => 404, :message => "Not Found")
    def initialize(arg = nil)
      if arg.is_a? Hash
        if arg.key?(:message) || arg.key?('message')
          super(arg[:message] || arg['message'])
        else
          super arg
        end

        arg.each do |k, v|
          instance_variable_set "@#{k}", v
        end
      else
        super arg
      end
    end
  end

  class NotFoundError < ApiError
  end

  class UnauthorizedError < ApiError
  end

  class ForbiddenError < ApiError
  end

  class ServiceError < ApiError
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mux_ruby-1.3.0 lib/mux_ruby/api_error.rb
mux_ruby-1.0.0 lib/mux_ruby/api_error.rb