Class: LoomException

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

Defined Under Namespace

Classes: LoomDown, LoomError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, api_key) ⇒ LoomException

Returns a new instance of LoomException.



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

def initialize(url, api_key)
   = { :url => url, :api_key => api_key }
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



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

def cookies
  @cookies
end

#exceptionObject

Returns the value of attribute exception.



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

def exception
  @exception
end

#remote_ipObject

Returns the value of attribute remote_ip.



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

def remote_ip
  @remote_ip
end

#request_parametersObject

Returns the value of attribute request_parameters.



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

def request_parameters
  @request_parameters
end

#sessionObject

Returns the value of attribute session.



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

def session
  @session
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#user_idObject

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Class Method Details

.log(url, api_key, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/loom_exception.rb', line 25

def self.log(url, api_key, &block)
  loom = new url, api_key
  yield loom
  loom.send_to_loom
rescue LoomDown # TODO
  # Timed out or Loom down.  Log the error and optionally email the administrator.
rescue LoomError # TODO
  # We sent an invalid request.  Log the error and optionally email the administrator.
rescue Exception # TODO
  # Something else happened, log it.  The user will be shown an error page so they
  # can acknowledge the issue and continue using the application.
end

Instance Method Details

#send_to_loomObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/loom_exception.rb', line 14

def send_to_loom
  response = post
  
  if response.code.match /^2/
    true
  else
    puts response.message
    puts response.body
  end
end