errorkit 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b3a8d7d3ae4c413ca53a1f7d0463e80ddae34db
4
- data.tar.gz: e55ce216c6f4d957e29883a3fde546fa52bd22cf
3
+ metadata.gz: f2b7253a2149514a9a632edbc520aa150a8197a8
4
+ data.tar.gz: cd87a967fea8dc4b8bc0455a40f33f72719fb941
5
5
  SHA512:
6
- metadata.gz: db9a77577712658b5af7d04aa64bca059343191d465deecad12a3b017c223cf1c8760daf8cd2fb1d770ab57693a55170d223c72fdeabd8a9414590fc9e26ab6a
7
- data.tar.gz: 417b54060cd71254cd200e5b01729e34ea260780b056352886f99cafb9e95045a128b9809f37e42515fdd28936c6396391e06b6e2906cb70de74bf7cbb7e4a54
6
+ metadata.gz: 4c644359b347b965202530afd86c47886edb376d56545bc8e06eae50da6b1ffa5a9abe1bad9ec122173cfb00dc85a90d26b26e177bfc6bd75242460ae5b897ae
7
+ data.tar.gz: 1cb701c40ff18992e83abd1435995cd080ff99686da3ab734df970e7eb6ef576006b37428530f106657e38f31b36d1ccb9285c0f74d153f780d0934b2b5e2191
data/README.md CHANGED
@@ -50,7 +50,7 @@ You can override the default configuration in config/initializers/errorkit.rb.
50
50
 
51
51
  From this point you can customize most things. Errorkit handles errors
52
52
  that occur within your application and displays a corresponding template.
53
- By default, it uses app/views/errors/error.html.erb which you should
53
+ By default, it uses app/views/errors/show.html.erb which you should
54
54
  customize. If you want to have specific templates for specific pages
55
55
  you can create them by name:
56
56
 
@@ -68,7 +68,7 @@ You can extend this list of defaults as well. See
68
68
  http://guides.rubyonrails.org/layouts_and_rendering.html for more information.
69
69
 
70
70
  It is also possible to customize the notification template found at
71
- app/views/errors/notification.html.erb.
71
+ app/views/errors/error_notification.html.erb.
72
72
 
73
73
  ## Custom Errors Controller
74
74
 
@@ -33,7 +33,10 @@ module Errorkit
33
33
  end
34
34
 
35
35
  def mailer_subject
36
- "[#{error.environment || 'Error'}] #{error.exception}: #{error.message}"
36
+ message = error.message
37
+ message = message[0..27] + '...' if message.length > 30
38
+
39
+ "[#{error.environment || 'Error'}] #{error.exception}: #{message}"
37
40
  end
38
41
 
39
42
  def append_view_paths
@@ -0,0 +1,26 @@
1
+ require 'sidekiq'
2
+
3
+ module Errorkit
4
+ class Sidekiq
5
+ def call(worker, msg, queue)
6
+ begin
7
+ # Handle any setup
8
+ yield
9
+ rescue => ex
10
+ Errorkit.background_error(worker, msg, queue, ex)
11
+ raise
12
+ ensure
13
+ # Handle any cleanup
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ # Only connect if Sidekiq
20
+ if defined?(::Sidekiq)
21
+ ::Sidekiq.configure_server do |config|
22
+ config.server_middleware do |chain|
23
+ chain.add ::Errorkit::Sidekiq
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Errorkit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/errorkit.rb CHANGED
@@ -3,6 +3,7 @@ require 'errorkit/config'
3
3
  require 'errorkit/ignorable_error'
4
4
  require 'errorkit/errors_controller'
5
5
  require 'errorkit/errors_mailer'
6
+ require 'errorkit/sidekiq'
6
7
 
7
8
  module Errorkit
8
9
  require 'errorkit/engine' if defined?(Rails)
@@ -48,6 +49,28 @@ module Errorkit
48
49
  config.errors_controller.action(:show).call(env)
49
50
  end
50
51
 
52
+ def self.background_error(worker, payload, queue, exception)
53
+ unless config.errors_class.nil? || config.ignore_exception?(exception)
54
+ begin
55
+ error = config.errors_class.create(
56
+ server: server,
57
+ environment: environment,
58
+ version: application_version,
59
+ exception: exception.class.to_s,
60
+ message: exception.message,
61
+ backtrace: clean_backtrace(exception),
62
+ worker: worker,
63
+ queue: queue,
64
+ payload: payload
65
+ )
66
+ send_notification(error)
67
+ error
68
+ rescue Errorkit::IgnorableError
69
+ # noop
70
+ end
71
+ end
72
+ end
73
+
51
74
  def self.environment
52
75
  Rails.env.to_s if defined?(Rails)
53
76
  end
@@ -1,7 +1,38 @@
1
- There was an error:
2
-
3
- <%= error.exception %>
1
+ An <strong><%= error.exception %></strong> error occurred in <%= error.environment %> (error: <%= error.to_param %>):
4
2
 
5
3
  <p>
6
4
  <%= error.message %>
7
5
  </p>
6
+
7
+ <h5>Backtrace</h5>
8
+ <pre><%= error.backtrace %></pre>
9
+
10
+ <% if error.controller %>
11
+ <h5>Session</h5>
12
+ <pre><%= error.params %></pre>
13
+
14
+ <h5>Params</h5>
15
+ <pre><%= error.session %></pre>
16
+ <% end %>
17
+
18
+ <% if error.worker %>
19
+ <h5>Payload</h5>
20
+ <pre>
21
+ <%= error.payload %>
22
+ </pre>
23
+
24
+ <h5>Details</h5>
25
+ <ul>
26
+ <li>Environment: <%= error.environment %></li>
27
+ <li>Server: <%= error.server %></li>
28
+ <li>Version: <%= error.version %></li>
29
+ <% if error.controller %>
30
+ <li>Action: <%= error.controller %>#<%= error.action %></li>
31
+ <li>IP: <%= error.remote_ip %></li>
32
+ <li>URL: <%= error.url %></li>
33
+ <% end %>
34
+ <% if error.worker %>
35
+ <li>Worker: <%= error.worker %></li>
36
+ <li>Queue: <%= error.queue %></li>
37
+ <% end %>
38
+ </ul>
@@ -8,7 +8,7 @@ class CreateErrors < ActiveRecord::Migration
8
8
  t.string :server
9
9
  t.string :version
10
10
  t.string :exception
11
- t.string :message
11
+ t.text :message
12
12
  t.text :backtrace
13
13
  t.string :controller
14
14
  t.string :action
@@ -18,7 +18,7 @@ class CreateErrors < ActiveRecord::Migration
18
18
  t.string :worker
19
19
  t.string :queue
20
20
  t.string :payload
21
- t.string :url
21
+ t.text :url
22
22
  t.integer :user_id
23
23
  t.integer :subject_id
24
24
  t.string :subject_type
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errorkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Rafter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-26 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,7 @@ files:
87
87
  - lib/errorkit/errors_controller.rb
88
88
  - lib/errorkit/errors_mailer.rb
89
89
  - lib/errorkit/ignorable_error.rb
90
+ - lib/errorkit/sidekiq.rb
90
91
  - lib/errorkit/version.rb
91
92
  - lib/generators/errorkit/USAGE
92
93
  - lib/generators/errorkit/install_generator.rb