Exception: InfluxDB2::InfluxError
- Inherits:
 - 
      StandardError
      
        
- Object
 - StandardError
 - InfluxDB2::InfluxError
 
 
- Defined in:
 - lib/influxdb2/client/influx_error.rb
 
Overview
InfluxError that is raised during HTTP communication.
Constant Summary collapse
- HTTP_ERRORS =
 [ EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error ].freeze
Instance Attribute Summary collapse
- 
  
    
      #code  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
HTTP status code.
 - 
  
    
      #original  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
original error.
 - 
  
    
      #reference  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Reference code unique to the error type.
 - 
  
    
      #retry_after  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The Retry-After header describes when to try the request again.
 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #initialize(original = nil, message:, code:, reference:, retry_after:)  ⇒ InfluxError 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of InfluxError.
 
Constructor Details
#initialize(original = nil, message:, code:, reference:, retry_after:) ⇒ InfluxError
Returns a new instance of InfluxError.
      24 25 26 27 28 29 30 31  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 24 def initialize(original = nil, message:, code:, reference:, retry_after:) super() @code = code @reference = reference @retry_after = retry_after @original = original end  | 
  
Instance Attribute Details
#code ⇒ Object (readonly)
HTTP status code
      16 17 18  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 16 def code @code end  | 
  
#original ⇒ Object (readonly)
original error
      22 23 24  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 22 def original @original end  | 
  
#reference ⇒ Object (readonly)
Reference code unique to the error type
      18 19 20  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 18 def reference @reference end  | 
  
#retry_after ⇒ Object (readonly)
The Retry-After header describes when to try the request again.
      20 21 22  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 20 def retry_after @retry_after end  | 
  
Class Method Details
.from_error(error) ⇒ Object
      48 49 50 51  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 48 def self.from_error(error) obj = new(error, message: error., code: '', reference: '', retry_after: '') obj end  | 
  
.from_message(message) ⇒ Object
      43 44 45 46  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 43 def self.() obj = new(message: , code: '', reference: '', retry_after: '') obj end  | 
  
.from_response(response) ⇒ Object
      33 34 35 36 37 38 39 40 41  | 
    
      # File 'lib/influxdb2/client/influx_error.rb', line 33 def self.from_response(response) json = JSON.parse(response.body) obj = new(message: json['message'] || json['error'] || '', 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  |