Class: ExceptIO::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/exceptio/client.rb

Constant Summary collapse

DEFAULT_IGNORED_EXCEPTIONS =
["ActiveRecord::RecordNotFound", "ActionController::InvalidAuthenticityToken", "ActionController::RoutingError"]

Class Method Summary collapse

Class Method Details

.app_keyObject



31
32
33
# File 'lib/exceptio/client.rb', line 31

def self.app_key
  @app_key
end

.applicationObject



27
28
29
# File 'lib/exceptio/client.rb', line 27

def self.application
  @application
end

.configure(application, app_key, endpoint = 'except.io') ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/exceptio/client.rb', line 9

def self.configure(application, app_key, endpoint = 'except.io')
  @application = application
  @app_key = app_key
  @configured = true
  base_uri endpoint
  if defined?(Rails)
    if Rails.version.starts_with?("2.3")
      ActionController::Base.send(:include, ExceptIO::Hooks::Rails23)
    elsif Rails.version.starts_with?("3")
      ActionController::Base.send(:include, ExceptIO::Hooks::Rails3)
    end
  end
end

.configuredObject



23
24
25
# File 'lib/exceptio/client.rb', line 23

def self.configured
  @configured
end

.ignored_exceptionsObject



35
36
37
# File 'lib/exceptio/client.rb', line 35

def self.ignored_exceptions
  @ignored_exceptions ||= DEFAULT_IGNORED_EXCEPTIONS.clone
end

.ignored_exceptions=(ignored_exceptions) ⇒ Object



39
40
41
# File 'lib/exceptio/client.rb', line 39

def self.ignored_exceptions=(ignored_exceptions)
  @ignored_exceptions = ignored_exceptions
end

.log(exception, environment = "production", params = {}, session = {}, request_url = nil) ⇒ Object



50
51
52
53
54
55
# File 'lib/exceptio/client.rb', line 50

def self.log(exception, environment = "production", params = {}, session = {}, request_url = nil)
  return false unless self.configured
  return false if self.ignored_exceptions.map(&:to_s).include?(exception.class.name)
  res = self.post("/applications/#{self.application}/errors", {:query => {:app_key => self.app_key}, :body => {:error => {:message => exception.message, :backtrace => exception.backtrace, :type => exception.class.name, :environment => environment, :params => params, :session => session, :request_url => request_url}}})
  res.code == 201
end

.reset!Object



43
44
45
46
47
48
# File 'lib/exceptio/client.rb', line 43

def self.reset!
  @application = nil
  @app_key = nil
  @configured = false
  @ignored_exceptions = DEFAULT_IGNORED_EXCEPTIONS.clone
end