activeerror 1.0.10 → 1.1.0

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: '018a130d382073d7eb66c2f786dc6b2ad5b5ef59f26f4a4e717dd82d66cd9ed6'
4
+ data.tar.gz: 135d86e49142e37547f30add626f9f359b59afd7619961e25cf4c5b805598126
5
5
  SHA512:
6
- metadata.gz: 95ca3438ab73b030dcbddfbac75dd326b6484d04177a91510ef93931fcdc8d2612198b78f706eb4554c1f5d1b3edc4ea7f2ab6b7b33420c9a8f51525506cafda
7
- data.tar.gz: 132d1fc74d7c8e8ed8b695dd4a7357c5c3d3754b6faaa93997ed3878ce664ff016d6380c43207cd313b86a0ec2c2a681b2caa430faeeef11d4bbe9cd636f7c29
6
+ metadata.gz: da8062b4201ff1e12b224c2801805727270a52ab2f0d87cfacbc2e3e2c212093e4ae06649a59833934043e8c8b7662fa631ed2d3ca719351596c3a8786abe59d
7
+ data.tar.gz: 868fa1fc5fb9199c2352edfcb68e4d451a111c956a7c6a7293f9265a5c6dbe5e43a62c7422b8cf70c7e79ea446a0067baa5370d34a789d9116756e366acbb477
data/README.md CHANGED
@@ -47,6 +47,16 @@ bin/rails rails db:migrate
47
47
 
48
48
  This also mounts a route n your routes file to view the errors at `/errors`.
49
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
+ ```
59
+
50
60
  ## Development
51
61
 
52
62
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -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,7 +1,8 @@
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
@@ -13,7 +14,7 @@ module ActiveError
13
14
 
14
15
  ActiveJob::Base.before_perform do
15
16
  Rails.error.set_context(active_error_request:
16
- ActiveJobRequest.new(serialize, serialize))
17
+ ActiveJobRequest.new(serialize, serialize, self.class.name))
17
18
  rescue ActiveJob::SerializationError
18
19
  without_args = { "job_class" => self.class.name,
19
20
  "job_id" => job_id,
@@ -27,7 +28,7 @@ module ActiveError
27
28
  "enqueued_at" => Time.now.utc.iso8601(9),
28
29
  "scheduled_at" => scheduled_at&.utc&.iso8601(9) }
29
30
  Rails.error.set_context(active_error_request:
30
- ActiveJobRequest.new(without_args, without_args))
31
+ ActiveJobRequest.new(without_args, without_args, self.class.name))
31
32
  end
32
33
  end
33
34
  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,
@@ -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.0"
5
5
  end
data/lib/active_error.rb CHANGED
@@ -10,4 +10,5 @@ require "active_error/railtie"
10
10
  require "active_error/version"
11
11
 
12
12
  module ActiveError
13
+ mattr_accessor :ignored
13
14
  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.0
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-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails