mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 14:06:22 +00:00
Merge branch 'issue-10031' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
6b2e22e0f2
2 changed files with 20 additions and 13 deletions
|
@ -37,7 +37,7 @@ class GitlabNotifierJob < ApplicationJob
|
|||
}
|
||||
end
|
||||
|
||||
unless @issue['iid']
|
||||
if @issue['iid'].blank? && issue_data[:issue].blank?
|
||||
Rails.cache.delete(cache_key)
|
||||
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
|
||||
end
|
||||
|
@ -62,8 +62,8 @@ class GitlabNotifierJob < ApplicationJob
|
|||
# Si este trabajo genera una excepción va a entrar en un loop, así que
|
||||
# la notificamos por correo
|
||||
rescue Exception => e
|
||||
email_notification.call(e)
|
||||
email_notification.call(exception, options)
|
||||
email_notification.call(e, data: @issue)
|
||||
email_notification.call(exception, data: options)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -84,10 +84,14 @@ class GitlabNotifierJob < ApplicationJob
|
|||
exception.class.name,
|
||||
Digest::SHA1.hexdigest(exception.message),
|
||||
Digest::SHA1.hexdigest(backtrace&.first.to_s),
|
||||
Digest::SHA1.hexdigest(options.dig(:data, :params, 'errors').to_s)
|
||||
Digest::SHA1.hexdigest(errors.to_s)
|
||||
].join('/')
|
||||
end
|
||||
|
||||
def errors
|
||||
options.dig(:data, :params, 'errors') if options.dig(:data, :params).is_a? Hash
|
||||
end
|
||||
|
||||
# Define si es una excepción de javascript o local
|
||||
#
|
||||
# @see BacktraceJob
|
||||
|
@ -126,6 +130,7 @@ class GitlabNotifierJob < ApplicationJob
|
|||
# @return [String]
|
||||
def body
|
||||
@body ||= ''.dup.tap do |b|
|
||||
b << log_section
|
||||
b << request_section
|
||||
b << javascript_footer
|
||||
b << data_section
|
||||
|
@ -162,14 +167,16 @@ class GitlabNotifierJob < ApplicationJob
|
|||
|
||||
# @return [String]
|
||||
def log_section
|
||||
return '' unless options[:log]
|
||||
return '' unless options.dig(:data, :log)
|
||||
|
||||
<<~LOG
|
||||
# Log
|
||||
|
||||
```
|
||||
#{options[:log]}
|
||||
```
|
||||
# Build log
|
||||
|
||||
```
|
||||
#{options[:data].delete(:log)}
|
||||
```
|
||||
|
||||
LOG
|
||||
end
|
||||
|
||||
|
@ -257,8 +264,8 @@ class GitlabNotifierJob < ApplicationJob
|
|||
|
||||
## Data
|
||||
|
||||
```
|
||||
#{pp options[:data]}
|
||||
```yaml
|
||||
#{options[:data].to_yaml}
|
||||
```
|
||||
|
||||
DATA
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Enviar una notificación cuando falla una tarea
|
||||
SuckerPunch.exception_handler = lambda { |ex, _klass, _args|
|
||||
ExceptionNotifier.notify_exception(ex)
|
||||
SuckerPunch.exception_handler = lambda { |ex, _, args|
|
||||
ExceptionNotifier.notify_exception(ex, data: args)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue