solid_errors 0.6.1 → 0.7.1

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
  SHA256:
3
- metadata.gz: acc9e46b7ee94e391df6d5fa4b11fd0550dcef9eca0f1b2089ec8ea81d6dc47e
4
- data.tar.gz: 37fda129cbac297cb10da823a70188515f29f57f02160b2acf01fd010345698a
3
+ metadata.gz: f3f112f7c3ae7a71fa1f7d92be55cfa8e6fff8263fdff9a0c406c1db46c37126
4
+ data.tar.gz: fccfcd6e806e1f3fd17db5c89cc30f2c35302e6dc64b0a386f417bf1d28f8106
5
5
  SHA512:
6
- metadata.gz: 1f2cd0c74b2a38ac93abb353cc8083cb623b942cd117df06efaf246afc0e42e2cd40732692fb6e7510c2962fab5a3826d88c674c21d1c2582de8264a4ccbca82
7
- data.tar.gz: 1ecc1ebc03b277fa8840cdc3550ad0e64f566761a3ecdc5ad45a2daa39fde4b8922c528eec6fa3097fd15f098bfcbe7b372bc26197855e5507990d04e1729ce3
6
+ metadata.gz: f9415aa986a5ba6ff7491527f4cb053415df72fe73b585bd877f47e8e5ca869ba866210d9e32aac80373c43578b7efa59545dac9f82f808576f8ef80d60582b5
7
+ data.tar.gz: 1d0dd34c0920999496cd57e5729f3f18da0ca8c729b557d182cb9a47cfa3e8c038f1756a8d75fe5f08424e49d86db8050f85d2783e59751e7e778cc54d0282df
data/README.md CHANGED
@@ -24,13 +24,8 @@
24
24
  </a>
25
25
  </p>
26
26
 
27
-
28
27
  Solid Errors is a DB-based, app-internal exception tracker for Rails applications, designed with simplicity and performance in mind. It uses the new [Rails error reporting API](https://guides.rubyonrails.org/error_reporting.html) to store uncaught exceptions in the database, and provides a simple UI for viewing and managing exceptions.
29
28
 
30
- > [!WARNING]
31
- > The current point release of Rails (7.1.3.2) has a bug which severely limits the utility of Solid Errors. Exceptions raised during a web request *are not* reported to Rails' error reporter. There is a fix in the `main` branch, but it has not been released in a new point release. As such, Solid Errors is **not** production-ready unless you are running Rails from the `main` branch or until a new point version is released and you upgrade.
32
- > The original bug report can be found [here](https://github.com/rails/rails/issues/51002) and the pull request making the fix is [here](https://github.com/rails/rails/pull/51050). I will try to backport the fix into the gem directly, but I haven't quite figured it out yet.
33
-
34
29
 
35
30
  ## Installation
36
31
 
@@ -80,7 +75,7 @@ production:
80
75
  ```
81
76
 
82
77
  > [!NOTE]
83
- > Calling `bin/rails solid_errors:install` will automatically add `config.solid_errors.connects_to = { database: { writing: :errors } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `errors` name in `database.yml` for this to match!). But if you want to use Solid Errors in a different environment (like staging or even development), you'll have to manually add that `config.solid_errors.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_errors.connects_to`.
78
+ > Calling `bin/rails generate solid_errors:install` will automatically add `config.solid_errors.connects_to = { database: { writing: :errors } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `errors` name in `database.yml` for this to match!). But if you want to use Solid Errors in a different environment (like staging or even development), you'll have to manually add that `config.solid_errors.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_errors.connects_to`.
84
79
 
85
80
  Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
86
81
 
@@ -98,6 +93,12 @@ end
98
93
 
99
94
  All exceptions are recorded automatically. No additional code required.
100
95
 
96
+ You can add default additional information to the context of the error by adding this line to your application controller:
97
+ ```ruby
98
+ before_action { Rails.error.set_context(request_url: request.original_url, params: params, session: session.inspect) }
99
+ ```
100
+ The additional context information will be automatically displayed on the occurence details page.
101
+
101
102
  Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.
102
103
 
103
104
  There are intentionally few features; you can view and resolve errors. That’s it. The goal is to provide a simple, lightweight, and performant solution for tracking exceptions in your Rails application. If you need more features, you should probably use a 3rd party service like [Honeybadger](https://www.honeybadger.io/), whose MIT-licensed [Ruby agent gem](https://github.com/honeybadger-io/honeybadger-ruby) provided a couple of critical pieces of code for this project.
@@ -160,10 +161,13 @@ You can configure Solid Errors via the Rails configuration object, under the `so
160
161
  * `sends_email` - Whether or not to send emails when an error occurs. See [Email notifications](#email-notifications) for more information.
161
162
  * `email_from` - The email address to send a notification from. See [Email notifications](#email-notifications) for more information.
162
163
  * `email_to` - The email address(es) to send a notification to. See [Email notifications](#email-notifications) for more information.
164
+ * `email_subject_prefix` - Prefix added to the subject line for email notifications. See [Email notifications](#email-notifications) for more information.
165
+ * `base_controller_class` - Specify a different controller as the base class for the Solid Errors controller. See [Authentication](#authentication) for more information.
166
+ * `destroy_after` - If set, Solid Errors will periodically destroy resolved records that are older than the value specified. See [Automatically destroying old records](#automatically-destroying-old-records) for more information.
163
167
 
164
- #### Database Configuration
168
+ ### Database Configuration
165
169
 
166
- `config.solid_errors.connects_to` takes a custom database configuration hash that will be used in the abstract `SolidErrors::Record` Active Record model. This is required to use a different database than the main app. For example:
170
+ `config.solid_errors.connects_to` takes a custom database configuration hash that will be used in the abstract `SolidErrors::Record` Active Record model. This is required to use a different database than the main app ([but the primary database can also be used](#single-database-configuration)). For example:
167
171
 
168
172
  ```ruby
169
173
  # Use a single separate DB for Solid Errors
@@ -177,6 +181,16 @@ or
177
181
  config.solid_errors.connects_to = { database: { writing: :solid_errors_primary, reading: :solid_errors_replica } }
178
182
  ```
179
183
 
184
+ #### Single Database Configuration
185
+
186
+ Running Solid Errors in a separate database is recommended, but it's also possible to use one single database for both the app and the errors. Just follow these steps to add errors to the primary database:
187
+
188
+ 1. Copy the contents of `db/errors_schema.rb` into a normal migration and delete `db/errors_schema.rb`
189
+ 2. Remove `config.solid_errors.connects_to` from your configuration files.
190
+ 3. Migrate your database.
191
+
192
+ You won't have multiple databases, so `database.yml` doesn't need to have the errors database configuration.
193
+
180
194
  #### Authentication
181
195
 
182
196
  Solid Errors does not restrict access out of the box. You must secure the dashboard yourself. However, it does provide basic HTTP authentication that can be used with basic authentication or Devise. All you need to do is setup a username and password.
@@ -206,9 +220,16 @@ authenticate :user, -> (user) { user.admin? } do
206
220
  end
207
221
  ```
208
222
 
223
+ You can also specify a different controller to use as the Solid Errors controller base class:
224
+
225
+ ```ruby
226
+ # Override the base controller class with your own controller
227
+ config.solid_errors.base_controller_class = "YourAdminController"
228
+ ```
229
+
209
230
  #### Email notifications
210
231
 
211
- Solid Errors _can_ send email notifications whenever an error occurs, if your application has ActionMailer already properly setup to send emails. However, in order to activate this feature you must define the email address(es) to send the notifications to. Optionally, you can also define the email address to send the notifications from (useful if your email provider only allows emails to be sent from a predefined list of addresses) or simply turn off this feature altogether.
232
+ Solid Errors _can_ send email notifications whenever an error occurs, if your application has ActionMailer already properly setup to send emails. However, in order to activate this feature you must define the email address(es) to send the notifications to. Optionally, you can also define the email address to send the notifications from (useful if your email provider only allows emails to be sent from a predefined list of addresses) or simply turn off this feature altogether. You can also define a subject prefix for the email notifications to quickly identify the source of the error.
212
233
 
213
234
  There are two ways to configure email notifications. First, you can use environment variables:
214
235
 
@@ -216,19 +237,35 @@ There are two ways to configure email notifications. First, you can use environm
216
237
  ENV["SOLIDERRORS_SEND_EMAILS"] = true # defaults to false
217
238
  ENV["SOLIDERRORS_EMAIL_FROM"] = "errors@myapp.com" # defaults to "solid_errors@noreply.com"
218
239
  ENV["SOLIDERRORS_EMAIL_TO"] = "devs@myapp.com" # no default, must be set
240
+ ENV["SOLIDERRORS_EMAIL_SUBJECT_PREFIX"] = "[Application name][Environment]" # no default, optional
219
241
  ```
220
242
 
221
243
  Second, you can set the values via the configuration object:
222
244
 
223
245
  ```ruby
224
- # Set authentication credentials for Solid Errors
246
+ # Set authentication credentials and optional subject prefix for Solid Errors
225
247
  config.solid_errors.send_emails = true
226
248
  config.solid_errors.email_from = "errors@myapp.com"
227
249
  config.solid_errors.email_to = "devs@myapp.com"
250
+ config.solid_errors.email_subject_prefix = "[#{Rails.application.name}][#{Rails.env}]"
228
251
  ```
229
252
 
230
253
  If you have set `send_emails` to `true` and have set an `email_to` address, Solid Errors will send an email notification whenever an error occurs. If you have not set `send_emails` to `true` or have not set an `email_to` address, Solid Errors will not send any email notifications.
231
254
 
255
+ #### Automatically destroying old records
256
+
257
+ Setting `destroy_after` to a duration will allow Solid Errors to be self-maintaining by peridically destroying **resolved** records that are older than that value. The value provided must respond to `.ago`.
258
+
259
+ ```ruby
260
+ # Automatically destroy records older than 30 days
261
+ config.solid_errors.destroy_after = 30.days
262
+ ```
263
+
264
+ ```ruby
265
+ # Automatically destroy records older than 6 months
266
+ config.solid_errors.destroy_after = 6.months
267
+ ```
268
+
232
269
  ### Examples
233
270
 
234
271
  There are only two screens in the dashboard.
@@ -311,9 +348,20 @@ You can always take control of the views by creating your own views and/or parti
311
348
  </html>
312
349
  ```
313
350
 
351
+ ## Sponsors
352
+
353
+ <p align="center">
354
+ <em>Proudly sponsored by</em>
355
+ </p>
356
+ <p align="center">
357
+ <a href="https://www.honeybadger.io?utm_source=fractaledmind&utm_medium=open-source&utm_campaign=solid_errors">
358
+ <img src="https://honeybadger-static.s3.amazonaws.com/brand_assets/honeybadger_logo/honeybadger_logo.svg" width="575" />
359
+ </a>
360
+ </p>
361
+
314
362
  ## Development
315
363
 
316
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
364
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. If you want to set up a local development database, run `rake db:migrate`.
317
365
 
318
366
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
319
367
 
@@ -328,3 +376,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
328
376
  ## Code of Conduct
329
377
 
330
378
  Everyone interacting in the SolidErrors project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fractaledmind/solid_errors/blob/main/CODE_OF_CONDUCT.md).
379
+
data/Rakefile CHANGED
@@ -1,14 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bundler/setup"
4
+
5
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
6
+ load "rails/tasks/engine.rake"
7
+
3
8
  require "bundler/gem_tasks"
4
9
  require "rake/testtask"
10
+ require "standard/rake"
11
+
12
+ task default: %i[test standard]
5
13
 
6
14
  Rake::TestTask.new(:test) do |t|
7
15
  t.libs << "test"
8
16
  t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
17
+ t.test_files = FileList["test/**/*_test.rb"]
10
18
  end
11
-
12
- require "standard/rake"
13
-
14
- task default: %i[test standard]
@@ -1,5 +1,6 @@
1
1
  module SolidErrors
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < SolidErrors.base_controller_class.constantize
3
+ layout "solid_errors/application"
3
4
  protect_from_forgery with: :exception
4
5
 
5
6
  http_basic_authenticate_with name: SolidErrors.username, password: SolidErrors.password if SolidErrors.password
@@ -1,12 +1,27 @@
1
1
  module SolidErrors
2
2
  # adapted from: https://github.com/codergeek121/email_error_reporter/blob/main/lib/email_error_reporter/error_mailer.rb
3
- class ErrorMailer < ActionMailer::Base
3
+ class ErrorMailer < (defined?(ActionMailer::Base) ? ActionMailer::Base : Object)
4
+ if defined?(ActionMailer::Base)
5
+ # A failure here reported as usual would email again and fail again, without end
6
+ rescue_from StandardError do |exception|
7
+ SolidErrors.without_emails do
8
+ Rails.error.report(exception, handled: true, source: "solid_errors.error_mailer")
9
+ end
10
+ end
11
+ end
12
+
4
13
  def error_occurred(occurrence)
14
+ unless defined?(ActionMailer::Base)
15
+ raise "ActionMailer is not available. Make sure that you require \"action_mailer/railtie\" in application.rb"
16
+ end
5
17
  @occurrence = occurrence
6
18
  @error = occurrence.error
7
-
19
+ subject = "#{@error.severity_emoji} #{@error.exception_class}"
20
+ if SolidErrors.email_subject_prefix.present?
21
+ subject = [SolidErrors.email_subject_prefix, subject].join(" ").squish!
22
+ end
8
23
  mail(
9
- subject: "#{@error.severity_emoji} #{@error.exception_class}",
24
+ subject: subject,
10
25
  from: SolidErrors.email_from,
11
26
  to: SolidErrors.email_to
12
27
  )
@@ -35,7 +35,7 @@ module SolidErrors
35
35
  end
36
36
 
37
37
  def to_s
38
- lines.map(&:to_s).join("\n")
38
+ lines.join("\n")
39
39
  end
40
40
 
41
41
  def inspect
@@ -2,7 +2,7 @@ module SolidErrors
2
2
  # adapted from: https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/backtrace.rb
3
3
  class BacktraceLine
4
4
  # Backtrace line regexp (optionally allowing leading X: for windows support).
5
- INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}
5
+ INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in [`']([^']+)')?$}
6
6
  STRING_EMPTY = "".freeze
7
7
  GEM_ROOT = "[GEM_ROOT]".freeze
8
8
  PROJECT_ROOT = "[PROJECT_ROOT]".freeze
@@ -2,7 +2,11 @@ module SolidErrors
2
2
  class Occurrence < Record
3
3
  belongs_to :error, class_name: "SolidErrors::Error"
4
4
 
5
+ # Adapters that report the json column as text (MariaDB) would otherwise store Hash#inspect
6
+ attribute :context, :json
7
+
5
8
  after_create_commit :send_email, if: -> { SolidErrors.send_emails? && SolidErrors.email_to.present? }
9
+ after_create_commit :clear_resolved_errors, if: :should_clear_resolved_errors?
6
10
 
7
11
  # The parsed exception backtrace. Lines in this backtrace that are from installed gems
8
12
  # have the base path for gem installs replaced by "[GEM_ROOT]", while those in the project
@@ -11,7 +15,7 @@ module SolidErrors
11
15
  def parsed_backtrace
12
16
  return @parsed_backtrace if defined? @parsed_backtrace
13
17
 
14
- @parsed_backtrace = parse_backtrace(backtrace.split("\n"))
18
+ @parsed_backtrace = parse_backtrace(backtrace&.split("\n"))
15
19
  end
16
20
 
17
21
  private
@@ -23,5 +27,26 @@ module SolidErrors
23
27
  def send_email
24
28
  ErrorMailer.error_occurred(self).deliver_later
25
29
  end
30
+
31
+ def clear_resolved_errors
32
+ transaction do
33
+ SolidErrors::Occurrence
34
+ .where(error: SolidErrors::Error.resolved)
35
+ .where(created_at: ...SolidErrors.destroy_after.ago)
36
+ .delete_all
37
+ SolidErrors::Error.resolved
38
+ .where
39
+ .missing(:occurrences)
40
+ .delete_all
41
+ end
42
+ end
43
+
44
+ def should_clear_resolved_errors?
45
+ return false unless SolidErrors.destroy_after
46
+ return false unless SolidErrors.destroy_after.respond_to?(:ago)
47
+ return false unless (id % 100).zero?
48
+
49
+ true
50
+ end
26
51
  end
27
52
  end
@@ -1,4 +1,4 @@
1
- <style>
1
+ <style<% if local_assigns[:nonce] %> nonce="<%= nonce %>"<% end %>>
2
2
  /*
3
3
  ! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
4
4
  */
@@ -5,7 +5,7 @@
5
5
  <%= csrf_meta_tags %>
6
6
  <%= csp_meta_tag %>
7
7
 
8
- <%= render "layouts/solid_errors/style" %>
8
+ <%= render "layouts/solid_errors/style", nonce: content_security_policy_nonce %>
9
9
  </head>
10
10
  <body class="h-full flex flex-col pb-4">
11
11
  <main class="grow container mx-auto mt-4">
@@ -20,25 +20,25 @@
20
20
 
21
21
  <nav aria-label="Pages">
22
22
  <% if (first_page = page.first) %>
23
- <a href="<%= url_for(params.to_unsafe_hash.merge(page: first_page)) %>" aria-label="First" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&laquo;</a>
23
+ <a href="<%= url_for(page: first_page, items: params[:items]) %>" aria-label="First" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&laquo;</a>
24
24
  <% else %>
25
25
  <a role="link" aria-disabled="true" aria-label="First" class="border text-gray-500 bg-white py-1 px-2">&laquo;</a>
26
26
  <% end %>
27
27
 
28
28
  <% if (prev_page = page.prev) %>
29
- <a href="<%= url_for(params.to_unsafe_hash.merge(page: prev_page)) %>" aria-label="Previous" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&lsaquo;</a>
29
+ <a href="<%= url_for(page: prev_page, items: params[:items]) %>" aria-label="Previous" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&lsaquo;</a>
30
30
  <% else %>
31
31
  <a role="link" aria-disabled="true" aria-label="Previous" class="border text-gray-500 bg-white py-1 px-2">&lsaquo;</a>
32
32
  <% end %>
33
33
 
34
34
  <% if (next_page = page.next) %>
35
- <a href="<%= url_for(params.to_unsafe_hash.merge(page: next_page)) %>" aria-label="Next" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&rsaquo;</a>
35
+ <a href="<%= url_for(page: next_page, items: params[:items]) %>" aria-label="Next" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&rsaquo;</a>
36
36
  <% else %>
37
37
  <a role="link" aria-disabled="true" aria-label="Next" class="border text-gray-500 bg-white py-1 px-2">&rsaquo;</a>
38
38
  <% end %>
39
39
 
40
40
  <% if (last_page = page.last) %>
41
- <a href="<%= url_for(params.to_unsafe_hash.merge(page: last_page)) %>" aria-label="Last" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&raquo;</a>
41
+ <a href="<%= url_for(page: last_page, items: params[:items]) %>" aria-label="Last" class="border border-black text-black bg-white py-1 px-2 cursor-pointer hover:bg-black hover:text-white">&raquo;</a>
42
42
  <% else %>
43
43
  <a role="link" aria-disabled="true" aria-label="Last" class="border text-gray-500 bg-white py-1 px-2">&raquo;</a>
44
44
  <% end %>
@@ -10,6 +10,11 @@ module SolidErrors
10
10
  config.solid_errors.each do |name, value|
11
11
  SolidErrors.public_send(:"#{name}=", value)
12
12
  end
13
+
14
+ if SolidErrors.send_emails? && !defined?(ActionMailer)
15
+ raise "You have configured solid_errors.send_emails = true but ActionMailer is not available." \
16
+ "Make sure that you require \"action_mailer/railtie\" in application.rb or set solid_errors.send_emails = false."
17
+ end
13
18
  end
14
19
 
15
20
  initializer "solid_errors.active_record.error_subscriber" do
@@ -39,7 +39,7 @@ module SolidErrors
39
39
 
40
40
  SolidErrors::Occurrence.create(
41
41
  error_id: record.id,
42
- backtrace: error.backtrace.join("\n"),
42
+ backtrace: error.backtrace&.join("\n"),
43
43
  context: s(context)
44
44
  )
45
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidErrors
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.1"
5
5
  end
data/lib/solid_errors.rb CHANGED
@@ -7,35 +7,39 @@ require_relative "solid_errors/engine"
7
7
 
8
8
  module SolidErrors
9
9
  mattr_accessor :connects_to
10
+ mattr_accessor :base_controller_class, default: "::ActionController::Base"
10
11
  mattr_writer :username
11
12
  mattr_writer :password
12
- mattr_writer :send_emails
13
- mattr_writer :email_from
14
- mattr_writer :email_to
13
+ mattr_accessor :send_emails, default: false
14
+ mattr_accessor :email_from, default: "solid_errors@noreply.com"
15
+ mattr_accessor :email_to
16
+ mattr_accessor :email_subject_prefix
17
+ mattr_accessor :destroy_after
15
18
 
16
19
  class << self
17
20
  # use method instead of attr_accessor to ensure
18
- # this works if variable set after SolidErrors is loaded
21
+ # this works if ENV variable set after SolidErrors is loaded
19
22
  def username
20
23
  @username ||= ENV["SOLIDERRORS_USERNAME"] || @@username
21
24
  end
22
25
 
23
26
  # use method instead of attr_accessor to ensure
24
- # this works if variable set after SolidErrors is loaded
27
+ # this works if ENV variable set after SolidErrors is loaded
25
28
  def password
26
29
  @password ||= ENV["SOLIDERRORS_PASSWORD"] || @@password
27
30
  end
28
31
 
29
32
  def send_emails?
30
- @send_emails ||= ENV["SOLIDERRORS_SEND_EMAILS"] || @@send_emails || false
33
+ send_emails && email_to.present? && !ActiveSupport::IsolatedExecutionState[:solid_errors_without_emails]
31
34
  end
32
35
 
33
- def email_from
34
- @email_from ||= ENV["SOLIDERRORS_EMAIL_FROM"] || @@email_from || "solid_errors@noreply.com"
35
- end
36
-
37
- def email_to
38
- @email_to ||= ENV["SOLIDERRORS_EMAIL_TO"] || @@email_to
36
+ # Errors reported inside the block are recorded but never emailed
37
+ def without_emails
38
+ previous = ActiveSupport::IsolatedExecutionState[:solid_errors_without_emails]
39
+ ActiveSupport::IsolatedExecutionState[:solid_errors_without_emails] = true
40
+ yield
41
+ ensure
42
+ ActiveSupport::IsolatedExecutionState[:solid_errors_without_emails] = previous
39
43
  end
40
44
  end
41
45
  end
metadata CHANGED
@@ -1,99 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: actionmailer
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '7.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '7.0'
27
12
  - !ruby/object:Gem::Dependency
28
13
  name: actionpack
29
14
  requirement: !ruby/object:Gem::Requirement
30
15
  requirements:
31
16
  - - ">="
32
17
  - !ruby/object:Gem::Version
33
- version: '7.0'
18
+ version: '7.1'
34
19
  type: :runtime
35
20
  prerelease: false
36
21
  version_requirements: !ruby/object:Gem::Requirement
37
22
  requirements:
38
23
  - - ">="
39
24
  - !ruby/object:Gem::Version
40
- version: '7.0'
25
+ version: '7.1'
41
26
  - !ruby/object:Gem::Dependency
42
27
  name: actionview
43
28
  requirement: !ruby/object:Gem::Requirement
44
29
  requirements:
45
30
  - - ">="
46
31
  - !ruby/object:Gem::Version
47
- version: '7.0'
32
+ version: '7.1'
48
33
  type: :runtime
49
34
  prerelease: false
50
35
  version_requirements: !ruby/object:Gem::Requirement
51
36
  requirements:
52
37
  - - ">="
53
38
  - !ruby/object:Gem::Version
54
- version: '7.0'
39
+ version: '7.1'
55
40
  - !ruby/object:Gem::Dependency
56
41
  name: activerecord
57
42
  requirement: !ruby/object:Gem::Requirement
58
43
  requirements:
59
44
  - - ">="
60
45
  - !ruby/object:Gem::Version
61
- version: '7.0'
46
+ version: '7.1'
62
47
  type: :runtime
63
48
  prerelease: false
64
49
  version_requirements: !ruby/object:Gem::Requirement
65
50
  requirements:
66
51
  - - ">="
67
52
  - !ruby/object:Gem::Version
68
- version: '7.0'
53
+ version: '7.1'
69
54
  - !ruby/object:Gem::Dependency
70
55
  name: activesupport
71
56
  requirement: !ruby/object:Gem::Requirement
72
57
  requirements:
73
58
  - - ">="
74
59
  - !ruby/object:Gem::Version
75
- version: '7.0'
60
+ version: '7.1'
76
61
  type: :runtime
77
62
  prerelease: false
78
63
  version_requirements: !ruby/object:Gem::Requirement
79
64
  requirements:
80
65
  - - ">="
81
66
  - !ruby/object:Gem::Version
82
- version: '7.0'
67
+ version: '7.1'
83
68
  - !ruby/object:Gem::Dependency
84
69
  name: railties
85
70
  requirement: !ruby/object:Gem::Requirement
86
71
  requirements:
87
72
  - - ">="
88
73
  - !ruby/object:Gem::Version
89
- version: '7.0'
74
+ version: '7.1'
90
75
  type: :runtime
91
76
  prerelease: false
92
77
  version_requirements: !ruby/object:Gem::Requirement
93
78
  requirements:
94
79
  - - ">="
95
80
  - !ruby/object:Gem::Version
96
- version: '7.0'
81
+ version: '7.1'
97
82
  - !ruby/object:Gem::Dependency
98
83
  name: sqlite3
99
84
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +93,6 @@ dependencies:
108
93
  - - ">="
109
94
  - !ruby/object:Gem::Version
110
95
  version: '0'
111
- description:
112
96
  email:
113
97
  - stephen.margheim@gmail.com
114
98
  executables: []
@@ -125,7 +109,7 @@ files:
125
109
  - app/models/solid_errors/error.rb
126
110
  - app/models/solid_errors/occurrence.rb
127
111
  - app/models/solid_errors/record.rb
128
- - app/views/layouts/solid_errors/_style.html
112
+ - app/views/layouts/solid_errors/_style.html.erb
129
113
  - app/views/layouts/solid_errors/application.html.erb
130
114
  - app/views/solid_errors/error_mailer/error_occurred.html.erb
131
115
  - app/views/solid_errors/error_mailer/error_occurred.text.erb
@@ -154,7 +138,6 @@ licenses:
154
138
  metadata:
155
139
  homepage_uri: https://github.com/fractaledmind/solid_errors
156
140
  source_code_uri: https://github.com/fractaledmind/solid_errors
157
- post_install_message:
158
141
  rdoc_options: []
159
142
  require_paths:
160
143
  - lib
@@ -162,15 +145,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
145
  requirements:
163
146
  - - ">="
164
147
  - !ruby/object:Gem::Version
165
- version: 2.6.0
148
+ version: 3.2.0
166
149
  required_rubygems_version: !ruby/object:Gem::Requirement
167
150
  requirements:
168
151
  - - ">="
169
152
  - !ruby/object:Gem::Version
170
153
  version: '0'
171
154
  requirements: []
172
- rubygems_version: 3.5.11
173
- signing_key:
155
+ rubygems_version: 4.0.16
174
156
  specification_version: 4
175
157
  summary: Database-backed Rails error subscriber
176
158
  test_files: []