Sha256: b2e82071d519087314bf76f0386cb5c823f8ce95489aa1d38151ddb32bdd63c1

Contents?: true

Size: 525 Bytes

Versions: 7

Compression:

Stored size: 525 Bytes

Contents

class ZabbixApi
  class BaseError < RuntimeError
    attr_accessor :response, :error, :error_message

    def initialize(message, response = nil)
      super(message)
      @response = response

      set_error! if @response
    end

  private

    def set_error!
      @error = @response['error']
      @error_message = "#{@error['message']}: #{@error['data']}"
    rescue StandardError
      @error = nil
      @error_message = nil
    end
  end

  class ApiError < BaseError
  end

  class HttpError < BaseError
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
zabbixapi_mgx-7.2.0 lib/zabbixapi/classes/errors.rb
zabbixapi_mgx-5.0.0.pre.alpha2 lib/zabbixapi/classes/errors.rb
zabbixapi_mgx-5.0.0.pre.alpha1 lib/zabbixapi/classes/errors.rb
zabbixapi-5.0.0.pre.alpha1 lib/zabbixapi/classes/errors.rb
zabbixapi-4.2.0 lib/zabbixapi/classes/errors.rb
zabbixapi-4.1.2 lib/zabbixapi/classes/errors.rb
zabbixapi-4.1.1 lib/zabbixapi/classes/errors.rb