Class: SynapseClient::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception, request) ⇒ Error

Returns a new instance of Error.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/synapse_client/error.rb', line 11

def initialize(exception, request)
  @exception = exception
  @request   = request

  #
    begin
      @message = @exception["reason"] || @exception["message"]
      @title   = @exception["title"]
    rescue => e
      # FIXME
      # Rails.logger.error("Something went wrong with interacting with Synapse: #{ @exception.message }")
      return
    end

  #
    if @message.present? && @message.match(/error.*oauth.*authentication/i).present?
      refreshed_tokens = SynapseClient::RefreshedTokens.new({
          :old_access_token => @request.customer_access_token,
          :old_refresh_token => @request.customer_refresh_token
        })

      refreshed_tokens.refresh_old_tokens
    end

end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/synapse_client/error.rb', line 7

def code
  @code
end

#exceptionObject (readonly)

Returns the value of attribute exception.



8
9
10
# File 'lib/synapse_client/error.rb', line 8

def exception
  @exception
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/synapse_client/error.rb', line 5

def message
  @message
end

#requestObject (readonly)

Returns the value of attribute request.



9
10
11
# File 'lib/synapse_client/error.rb', line 9

def request
  @request
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/synapse_client/error.rb', line 6

def title
  @title
end

Instance Method Details

#msgObject



37
38
39
# File 'lib/synapse_client/error.rb', line 37

def msg
  (title || message).to_s
end