activeerror 1.0.10 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f6d62af5f9195a4f1e3012e151ed740dcae223987e918f3fb19fdf5e26c1922
4
- data.tar.gz: 478826e805487fc495f96f0edfadc443bef5162d7c3355de8ac69960e584d0b9
3
+ metadata.gz: cf8f5a1ee01022330a7ab7fd51b9d49e5bd39a1fa3ac4430c90e1321b7d4d2a1
4
+ data.tar.gz: f36c4e1b8052c14316e14075c9de5624ac3a09ee0816164f3d5e064f0bf6f55b
5
5
  SHA512:
6
- metadata.gz: 95ca3438ab73b030dcbddfbac75dd326b6484d04177a91510ef93931fcdc8d2612198b78f706eb4554c1f5d1b3edc4ea7f2ab6b7b33420c9a8f51525506cafda
7
- data.tar.gz: 132d1fc74d7c8e8ed8b695dd4a7357c5c3d3754b6faaa93997ed3878ce664ff016d6380c43207cd313b86a0ec2c2a681b2caa430faeeef11d4bbe9cd636f7c29
6
+ metadata.gz: 81a4a5f81fd404d6d154ad6a65d27dc2f5690113d0b2f4b284d1a878295734526d9be88ae2cf0fd71c8c7d46b358b4e9aaf382abcb9578f16990ea2a6d46fe0d
7
+ data.tar.gz: ee9c6c4bca50c0dd8220b12c112bdfcc20d88b646cbc1c15cca1425d46c5a9768d9f1c9fc963c9febf8352f90936f0e16b4c868fbd6a565979b96c3c2c66f685
data/README.md CHANGED
@@ -19,8 +19,8 @@ noise) and then we recreate the error and display it using the built in debug
19
19
  view from Rails. Once you've resolved the error you can click "Resolve" which
20
20
  will destroy the record.
21
21
 
22
- ![screenshot 1](https://github.com/npezza93/active_error/blob/main/.github/screenshot1.png)
23
- ![screenshot 2](https://github.com/npezza93/active_error/blob/main/.github/screenshot2.png)
22
+ ![screenshot 1](https://github.com/npezza93/activeerror/blob/main/.github/screenshot1.png)
23
+ ![screenshot 2](https://github.com/npezza93/activeerror/blob/main/.github/screenshot2.png)
24
24
 
25
25
  ## Installation
26
26
  Add this line to your application's Gemfile:
@@ -41,11 +41,21 @@ $ gem install activeerror
41
41
 
42
42
  And then install migrations:
43
43
  ```bash
44
- bin/rails active_error:install
44
+ bin/rails generate active_error:install
45
45
  bin/rails rails db:migrate
46
46
  ```
47
47
 
48
- This also mounts a route n your routes file to view the errors at `/errors`.
48
+ This also mounts a route in your routes file to view the errors at `/errors`.
49
+
50
+
51
+ ##### Config
52
+
53
+ You can supply the string version of an error class to `ignored` to ignore
54
+ classes of errors.
55
+
56
+ ```ruby
57
+ ActiveError.ignored = ["NoMethodError"]
58
+ ```
49
59
 
50
60
  ## Development
51
61
 
@@ -60,7 +70,7 @@ push git commits and tags, and push the `.gem` file to GitHub.
60
70
  ## Contributing
61
71
 
62
72
  Bug reports and pull requests are welcome on
63
- [GitHub](https://github.com/npezza93/active_error). This project is intended to
73
+ [GitHub](https://github.com/npezza93/activeerror). This project is intended to
64
74
  be a safe, welcoming space for collaboration, and contributors are expected to
65
75
  adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
66
76
  conduct.
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html class="active_error">
3
3
  <head>
4
- <title>Active error</title>
4
+ <title>Errors</title>
5
5
  <%= csrf_meta_tags %>
6
6
  <%= csp_meta_tag %>
7
7
 
@@ -56,7 +56,8 @@
56
56
  }
57
57
 
58
58
  .active_error #notice {
59
- color: #d3f0b7;
59
+ color: green;
60
+ margin: 0px;
60
61
  }
61
62
 
62
63
  .active_error header {
@@ -65,6 +66,7 @@
65
66
  padding: 0.5em 1.5em;
66
67
  display: flex;
67
68
  flex-direction: row;
69
+ align-items: center;
68
70
  margin-bottom: 0.83em;
69
71
  }
70
72
 
@@ -38,8 +38,7 @@ module ActiveError
38
38
 
39
39
  def fault_attrs
40
40
  { backtrace: exception.backtrace, klass: exception.class.to_s,
41
- controller: parameters.to_h[:controller],
42
- action: parameters.to_h[:action] }
41
+ controller:, action: controller_action }
43
42
  end
44
43
 
45
44
  def template?
@@ -76,5 +75,15 @@ module ActiveError
76
75
  fault.instances.create(headers:, parameters: request&.filtered_parameters,
77
76
  url: request&.url)
78
77
  end
78
+
79
+ def controller
80
+ parameters.to_h[:controller].presence ||
81
+ request.try(:controller_class).to_s.presence
82
+ end
83
+
84
+ def controller_action
85
+ parameters.to_h[:action].presence ||
86
+ request.try(:controller_instance).try(:action_name).presence
87
+ end
79
88
  end
80
89
  end
@@ -1,19 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveError
4
- ActiveJobRequest = Struct.new(:parameters, :filtered_parameters, :env, :url)
4
+ ActiveJobRequest = Struct.new(:parameters, :filtered_parameters,
5
+ :controller_class, :env, :url)
5
6
 
6
7
  class Engine < ::Rails::Engine
7
8
  isolate_namespace ActiveError
8
9
 
9
- initializer "active_error.middleware" do |_app|
10
+ initializer "active_error.middleware" do |app|
11
+ app.config.middleware.use ActiveError::Middleware
12
+
10
13
  ActionController::Base.before_action do
11
14
  Rails.error.set_context(active_error_request: request)
12
15
  end
13
16
 
14
17
  ActiveJob::Base.before_perform do
15
18
  Rails.error.set_context(active_error_request:
16
- ActiveJobRequest.new(serialize, serialize))
19
+ ActiveJobRequest.new(serialize, serialize, self.class.name))
17
20
  rescue ActiveJob::SerializationError
18
21
  without_args = { "job_class" => self.class.name,
19
22
  "job_id" => job_id,
@@ -27,7 +30,7 @@ module ActiveError
27
30
  "enqueued_at" => Time.now.utc.iso8601(9),
28
31
  "scheduled_at" => scheduled_at&.utc&.iso8601(9) }
29
32
  Rails.error.set_context(active_error_request:
30
- ActiveJobRequest.new(without_args, without_args))
33
+ ActiveJobRequest.new(without_args, without_args, self.class.name))
31
34
  end
32
35
  end
33
36
  end
@@ -4,6 +4,12 @@
4
4
 
5
5
  module ActiveError
6
6
  module ExceptionMock
7
+ class Klass < SimpleDelegator
8
+ def name
9
+ self
10
+ end
11
+ end
12
+
7
13
  class Default < StandardError
8
14
  # include ActiveSupport::Dependencies::Blamable
9
15
 
@@ -17,7 +23,7 @@ module ActiveError
17
23
  end
18
24
 
19
25
  def class
20
- klass.constantize
26
+ Klass.new(klass)
21
27
  end
22
28
 
23
29
  attr_reader :backtrace, :backtrace_locations, :message, :cause,
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveError
4
+ class Middleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ @app.call(env)
11
+ rescue StandardError => e
12
+ unless Rails.application.config.reloading_enabled?
13
+ Rails.error.report(e, handled: false,
14
+ source: "application.action_dispatch")
15
+ end
16
+ raise
17
+ end
18
+ end
19
+ end
@@ -3,7 +3,8 @@
3
3
  module ActiveError
4
4
  class ErrorSubscriber
5
5
  def report(exception, context:, handled:, **_opts)
6
- return if Rails.env.local? || handled
6
+ return if Rails.env.development? || handled ||
7
+ ActiveError.ignored.to_a.include?(exception.class.to_s)
7
8
 
8
9
  Captor.new(exception:, request: context[:active_error_request]).capture
9
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveError
4
- VERSION = "1.0.10"
4
+ VERSION = "1.1.1"
5
5
  end
data/lib/active_error.rb CHANGED
@@ -4,10 +4,12 @@ require "active_error/exception_mock/default"
4
4
  require "active_error/exception_mock/template_error"
5
5
  require "active_error/exception_mock"
6
6
  require "active_error/captor"
7
+ require "active_error/middleware"
7
8
  require "active_error/renderer"
8
9
  require "active_error/engine"
9
10
  require "active_error/railtie"
10
11
  require "active_error/version"
11
12
 
12
13
  module ActiveError
14
+ mattr_accessor :ignored
13
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeerror
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/active_error/exception_mock.rb
67
67
  - lib/active_error/exception_mock/default.rb
68
68
  - lib/active_error/exception_mock/template_error.rb
69
+ - lib/active_error/middleware.rb
69
70
  - lib/active_error/railtie.rb
70
71
  - lib/active_error/renderer.rb
71
72
  - lib/active_error/version.rb