Class: RailsExceptionHandler::Storage

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

Class Method Summary collapse

Class Method Details

.active_record(info) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/rails_exception_handler/storage.rb', line 2

def self.active_record(info)
  if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0
    RailsExceptionHandler::ActiveRecord::ErrorMessage.create(info, :without_protection => true) if RailsExceptionHandler::ActiveRecord::ErrorMessage.respond_to?(:create)
  else
    RailsExceptionHandler::ActiveRecord::ErrorMessage.create(info) if RailsExceptionHandler::ActiveRecord::ErrorMessage.respond_to?(:create)
  end
end

.email(recipients, info) ⇒ Object

Notify application admin that an error occured



33
34
35
36
37
38
39
40
41
# File 'lib/rails_exception_handler/storage.rb', line 33

def self.email(recipients,info)
  return if recipients.blank?
  if Rails::VERSION::MAJOR == 3 || (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR < 2)
    delivery_method = :deliver
  else
    delivery_method = :deliver_now
  end
  RailsExceptionHandler::ErrorMailer.send_error_mail_to_admin(info.to_json,recipients).send(delivery_method)
end

.mongoid(info) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rails_exception_handler/storage.rb', line 10

def self.mongoid(info)
  if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0
    RailsExceptionHandler::Mongoid::ErrorMessage.create(info, :without_protection => true) if RailsExceptionHandler::Mongoid::ErrorMessage.respond_to?(:create)
  else
    RailsExceptionHandler::Mongoid::ErrorMessage.create(info) if RailsExceptionHandler::Mongoid::ErrorMessage.respond_to?(:create)
  end
end

.rails_log(info) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rails_exception_handler/storage.rb', line 18

def self.rails_log(info)
  message = ""
  info.each do |key,val|
    message += "#{key.to_s.upcase}: #{val.to_s}\n"
  end
  Rails.logger.fatal(message)
end

.remote_url(target, info) ⇒ Object



26
27
28
29
30
# File 'lib/rails_exception_handler/storage.rb', line 26

def self.remote_url(target, info)
  uri = URI.parse(target)
  params = flatten_hash({:error_message => info})
  Net::HTTP::post_form(uri, params)
end