Class: DocusignDtr::Auth::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/docusign_dtr/auth/error.rb

Instance Method Summary collapse

Constructor Details

#initialize(response:) ⇒ Error

Returns a new instance of Error.



4
5
6
# File 'lib/docusign_dtr/auth/error.rb', line 4

def initialize(response:)
  @response = response
end

Instance Method Details

#buildObject



8
9
10
11
12
# File 'lib/docusign_dtr/auth/error.rb', line 8

def build
  return nil if @response.code == 200

  exception.new(full_message)
end

#exceptionObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/docusign_dtr/auth/error.rb', line 18

def exception
  case @response.code
  when 400
    general_error
  when 401
    DocusignDtr::Unauthorized
  when 403
    DocusignDtr::Forbidden
  when 204
    DocusignDtr::NoContent
  else
    StandardError
  end
end

#full_messageObject



14
15
16
# File 'lib/docusign_dtr/auth/error.rb', line 14

def full_message
  "Error communicating: Response code #{@response.code}"
end