Exception: HelloSign::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/hello_sign/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status_code = nil) ⇒ Error

Returns a new instance of Error.



32
33
34
# File 'lib/hello_sign/error.rb', line 32

def initialize(message = nil, status_code = nil)
  @message, @status_code = message, status_code
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/hello_sign/error.rb', line 3

def message
  @message
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



3
4
5
# File 'lib/hello_sign/error.rb', line 3

def status_code
  @status_code
end

Class Method Details

.from_error_name(error_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hello_sign/error.rb', line 5

def self.from_error_name(error_name)
  case error_name
  when 'bad_request'
    BadRequest
  when 'unauthorized'
    Unauthorized
  when 'forbidden'
    Forbidden
  when 'not_found'
    NotFound
  when 'unknown'
    Unknown
  when 'team_invite_failed'
    TeamInviteFailed
  when 'invalid_recipient'
    InvalidRecipient
  when 'convert_failed'
    ConvertFailed
  when 'signature_request_cancel_failed'
    SignatureRequestCancelFailed
  when 'maintenance'
    Maintenance
  else
    Error
  end
end

Instance Method Details

#to_sObject



36
37
38
# File 'lib/hello_sign/error.rb', line 36

def to_s
  status_code ? message_with_status_code : message
end