Exception: WorkOS::WorkOSError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/workos/errors.rb

Overview

Parent class for WorkOS related errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message: nil, error: nil, error_description: nil, http_status: nil, request_id: nil, code: nil, errors: nil, data: nil, retry_after: nil) ⇒ WorkOSError

rubocop:disable Metrics/ParameterLists



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/workos/errors.rb', line 16

def initialize(
  message: nil,
  error: nil,
  error_description: nil,
  http_status: nil,
  request_id: nil,
  code: nil,
  errors: nil,
  data: nil,
  retry_after: nil
)
  @message = message
  @error = error
  @error_description = error_description
  @http_status = http_status
  @request_id = request_id
  @code = code
  @errors = errors
  @data = data
  @retry_after = retry_after
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



8
9
10
# File 'lib/workos/errors.rb', line 8

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/workos/errors.rb', line 12

def data
  @data
end

#errorObject (readonly)

Returns the value of attribute error.



10
11
12
# File 'lib/workos/errors.rb', line 10

def error
  @error
end

#error_descriptionObject (readonly)

Returns the value of attribute error_description.



11
12
13
# File 'lib/workos/errors.rb', line 11

def error_description
  @error_description
end

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/workos/errors.rb', line 9

def errors
  @errors
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



6
7
8
# File 'lib/workos/errors.rb', line 6

def http_status
  @http_status
end

#request_idObject (readonly)

Returns the value of attribute request_id.



7
8
9
# File 'lib/workos/errors.rb', line 7

def request_id
  @request_id
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



13
14
15
# File 'lib/workos/errors.rb', line 13

def retry_after
  @retry_after
end

Instance Method Details

#to_sObject

rubocop:enable Metrics/ParameterLists



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/workos/errors.rb', line 39

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