class InfluxDB2::InfluxError

InfluxError that is raised during HTTP communication.

Constants

HTTP_ERRORS

Attributes

code[R]

HTTP status code

original[R]

original error

reference[R]

Reference code unique to the error type

retry_after[R]

The Retry-After header describes when to try the request again.

Public Class Methods

from_error(error) click to toggle source
# File lib/influxdb2/client/influx_error.rb, line 48
def self.from_error(error)
  obj = new(error, message: error.message, code: '', reference: '', retry_after: '')
  obj
end
from_message(message) click to toggle source
# File lib/influxdb2/client/influx_error.rb, line 43
def self.from_message(message)
  obj = new(message: message, code: '', reference: '', retry_after: '')
  obj
end
from_response(response) click to toggle source
# File lib/influxdb2/client/influx_error.rb, line 33
def self.from_response(response)
  json = JSON.parse(response.body)
  obj = new(message: json['message'] || '', code: response.code, reference: json['code'] || '',
            retry_after: response['Retry-After'] || '')
  obj
rescue JSON::ParserError
  new(message: response.body || '', code: response.code, reference: '',
      retry_after: response['Retry-After'] || '')
end
new(original = nil, message:, code:, reference:, retry_after:) click to toggle source
Calls superclass method
# File lib/influxdb2/client/influx_error.rb, line 24
def initialize(original = nil, message:, code:, reference:, retry_after:)
  super(message)

  @code = code
  @reference = reference
  @retry_after = retry_after
  @original = original
end