class WorkOS::WorkOSError

Parent class for WorkOS related errors

Attributes

http_status[R]
request_id[R]

Public Class Methods

new(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil) click to toggle source
# File lib/workos/errors.rb, line 22
def initialize(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil)
  @message = message
  @error = error
  @error_description = error_description
  @http_status = http_status
  @request_id = request_id
end

Public Instance Methods

to_s() click to toggle source
# File lib/workos/errors.rb, line 31
def to_s
  status_string = @http_status.nil? ? '' : "Status #{@http_status}, "
  id_string = @request_id.nil? ? '' : " - request ID: #{@request_id}"
  if @error && @error_description
    error_string = "error: #{@error}, error_description: #{@error_description}"
    "#{status_string}#{error_string}#{id_string}"
  elsif @error
    "#{status_string}#{@error}#{id_string}"
  else
    "#{status_string}#{@message}#{id_string}"
  end
end