exceptio-ruby 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +10 -0
  2. data/lib/exceptio/client.rb +14 -0
  3. metadata +3 -3
data/README.rdoc CHANGED
@@ -48,6 +48,16 @@ If you are using something other than Rails, or have additional areas outside of
48
48
 
49
49
  Everything besides the exception itself is optional, with the environment defaulting to "production" if not supplied.
50
50
 
51
+ You can also wrap blocks of code that you want to log and handle errors for, such as trapping for exceptions within data migration loops and the like:
52
+
53
+ ExceptIO::Client.handle "environment", params_hash, session_hash, "http://request/url" do
54
+ # some code that may or may not raise an exception
55
+ end
56
+
57
+ If the code block raises an exception, it'll be logged (as per your configuration), and the call will return nil.
58
+
59
+ Everything besides the block is optional, with the environment defaulting to "production" if not supplied.
60
+
51
61
  == REQUIREMENTS:
52
62
 
53
63
  exceptio-ruby depends upon httparty.
@@ -4,8 +4,12 @@ module ExceptIO
4
4
  class Client
5
5
  include HTTParty
6
6
 
7
+ VERSION = "0.1.5"
8
+
7
9
  DEFAULT_IGNORED_EXCEPTIONS = ["ActiveRecord::RecordNotFound", "ActionController::InvalidAuthenticityToken", "ActionController::RoutingError"]
8
10
 
11
+ headers "User-Agent" => "exceptio-ruby #{VERSION}"
12
+
9
13
  def self.configure(application, app_key, endpoint = 'except.io')
10
14
  @application = application
11
15
  @app_key = app_key
@@ -53,5 +57,15 @@ module ExceptIO
53
57
  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}}})
54
58
  res.code == 201
55
59
  end
60
+
61
+ def self.handle(environment = "production", params = {}, session = {}, request_url = nil, &block)
62
+ return unless block_given?
63
+ begin
64
+ yield
65
+ rescue
66
+ ExceptIO::Client.log($!, environment, params, session, request_url)
67
+ nil
68
+ end
69
+ end
56
70
  end
57
71
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Elliott Draper
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-04-07 00:00:00 +01:00
17
+ date: 2012-04-12 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency