email_error_reporter 0.1.0.pre → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -29
- data/lib/email_error_reporter/railtie.rb +4 -0
- data/lib/email_error_reporter/version.rb +1 -1
- data/lib/email_error_reporter.rb +2 -6
- data/lib/tasks/email_error_reporter_tasks.rake +4 -12
- metadata +3 -9
- data/app/views/email_error_reporter/error_mailer/_frame.html.erb +0 -1
- data/app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb +0 -1
- data/app/views/email_error_reporter/error_mailer/error.html.erb +0 -6
- data/lib/email_error_reporter/engine.rb +0 -17
- data/lib/email_error_reporter/error_mailer.rb +0 -18
- data/lib/email_error_reporter/exception_serializer.rb +0 -23
- data/lib/email_error_reporter/subscriber.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e8f1858125082a54222230c31cc9f86977225bb52e4d58250415c6b0cb7c47d
|
4
|
+
data.tar.gz: 2c6a173d38e6d7b58cfea1291dfd5aa2dce6dd5b31e5907fe72772c96055ab8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928f4ed5561244626c6968949f531931ac2d24daa8d85912346d6c80ea4b06789a678af0f03767c4170fe8d0021392a09ab60dafa1a5d4a50827e41893460376
|
7
|
+
data.tar.gz: e4c5f4044e603434cd92504f37c386af900cbb1351abc6b7270a34268aed6d4a2d73a05b138f583b37ff9229583bd6d2c899c0fa8bf8321a989b833eadee5c74
|
data/README.md
CHANGED
@@ -1,43 +1,28 @@
|
|
1
1
|
# EmailErrorReporter
|
2
|
+
Short description and motivation.
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
`email_error_reporter` uses the new [Rails error reporting API](https://guides.rubyonrails.org/error_reporting.html#error-reporting) to send emails whenever an exception is being reported. It works out of the box with HTTP requests, jobs and the rails runner.
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
7
6
|
|
8
7
|
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
9
|
|
10
|
-
|
10
|
+
```ruby
|
11
|
+
gem "email_error_reporter"
|
12
|
+
```
|
11
13
|
|
14
|
+
And then execute:
|
12
15
|
```bash
|
13
|
-
|
16
|
+
$ bundle
|
14
17
|
```
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# application.rb
|
20
|
-
config.email_error_reporter.to = ["youremail@example.com"]
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install email_error_reporter
|
21
22
|
```
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
## Usage
|
26
|
-
|
27
|
-
All exceptions are reported automatically. No additional code required.
|
28
|
-
|
29
|
-
Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.
|
30
|
-
|
31
|
-
## Test your setup
|
32
|
-
|
33
|
-
You can use the built-in rake task `rake email_error_reporter:check` to check if everything works correctly in your setup.
|
34
|
-
|
35
|
-
If you're using Kamal, you can run the following command to test the setup in production:
|
36
|
-
|
37
|
-
```
|
38
|
-
kamal app exec -p 'bundle exec rake email_error_reporter:test_email'
|
39
|
-
```
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
40
26
|
|
41
27
|
## License
|
42
|
-
|
43
28
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/email_error_reporter.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require "email_error_reporter/version"
|
2
|
-
require "email_error_reporter/
|
2
|
+
require "email_error_reporter/railtie"
|
3
3
|
|
4
4
|
module EmailErrorReporter
|
5
|
-
|
6
|
-
|
7
|
-
autoload :ErrorMailer
|
8
|
-
autoload :Subscriber
|
9
|
-
autoload :ExceptionSerializer
|
5
|
+
# Your code goes here...
|
10
6
|
end
|
@@ -1,12 +1,4 @@
|
|
1
|
-
desc "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
$stdout.puts <<~TXT
|
6
|
-
Test exception triggered.
|
7
|
-
|
8
|
-
Recipients:
|
9
|
-
#{Rails.application.config.email_error_reporter.to.join("\n").gsub(/^/, "* ")}
|
10
|
-
TXT
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :email_error_reporter do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_error_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas Haeusele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -34,14 +34,8 @@ files:
|
|
34
34
|
- MIT-LICENSE
|
35
35
|
- README.md
|
36
36
|
- Rakefile
|
37
|
-
- app/views/email_error_reporter/error_mailer/_frame.html.erb
|
38
|
-
- app/views/email_error_reporter/error_mailer/_no_backtrace.html.erb
|
39
|
-
- app/views/email_error_reporter/error_mailer/error.html.erb
|
40
37
|
- lib/email_error_reporter.rb
|
41
|
-
- lib/email_error_reporter/
|
42
|
-
- lib/email_error_reporter/error_mailer.rb
|
43
|
-
- lib/email_error_reporter/exception_serializer.rb
|
44
|
-
- lib/email_error_reporter/subscriber.rb
|
38
|
+
- lib/email_error_reporter/railtie.rb
|
45
39
|
- lib/email_error_reporter/version.rb
|
46
40
|
- lib/tasks/email_error_reporter_tasks.rake
|
47
41
|
homepage: https://github.com/codergeek121/email_error_reporter
|
@@ -1 +0,0 @@
|
|
1
|
-
<li><%= frame %></li>
|
@@ -1 +0,0 @@
|
|
1
|
-
<p>No backtrace available</p>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module EmailErrorReporter
|
2
|
-
class Engine < ::Rails::Engine
|
3
|
-
isolate_namespace EmailErrorReporter
|
4
|
-
|
5
|
-
config.email_error_reporter = ActiveSupport::OrderedOptions.new
|
6
|
-
config.email_error_reporter.to = []
|
7
|
-
|
8
|
-
initializer "email_error_reporter.error_subscribe" do
|
9
|
-
Rails.error.subscribe(Subscriber.new)
|
10
|
-
end
|
11
|
-
|
12
|
-
# ActiveJob cannot (de)-serialize exceptions by default
|
13
|
-
initializer "email_error_reporter.exception_serializer" do |app|
|
14
|
-
app.config.active_job.custom_serializers << ExceptionSerializer
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module EmailErrorReporter
|
2
|
-
class ErrorMailer < ActionMailer::Base
|
3
|
-
def error(error, handled:, severity:, context:, source: nil)
|
4
|
-
@error = error
|
5
|
-
@handled = handled
|
6
|
-
@severity = severity
|
7
|
-
@context = context
|
8
|
-
@source = source
|
9
|
-
|
10
|
-
@backtrace = Array.wrap(error.backtrace)
|
11
|
-
|
12
|
-
mail(
|
13
|
-
subject: "#{error.class}",
|
14
|
-
to: Rails.application.config.email_error_reporter.to
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module EmailErrorReporter
|
2
|
-
class ExceptionSerializer < ActiveJob::Serializers::ObjectSerializer
|
3
|
-
def serialize(exception)
|
4
|
-
super(
|
5
|
-
exception_class: exception.class.to_s,
|
6
|
-
message: exception.message,
|
7
|
-
backtrace: exception.backtrace
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
|
-
def deserialize(hash)
|
12
|
-
hash[:exception_class].constantize.new(hash[:message]).tap do |e|
|
13
|
-
e.set_backtrace(hash[:backtrace])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def klass
|
20
|
-
Exception
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|