1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

ensure that we only try to log exceptions when raven is available

هذا الالتزام موجود في:
Adam Cooke
2017-04-26 20:54:50 +01:00
الأصل 3d45a5d4f1
التزام 0f10481da0
9 ملفات معدلة مع 33 إضافات و11 حذوفات

عرض الملف

@@ -27,7 +27,9 @@ module Postal
n.notify!(:short_message => message_without_ansi, :log_name => @log_name, :facility => 'postal', :application_name => 'postal', :process_name => ENV['PROC_NAME'], :pid => Process.pid)
rescue => e
# Can't log this to GELF. Soz.
Raven.capture_exception(e)
if defined?(Raven)
Raven.capture_exception(e)
end
end
end
true

عرض الملف

@@ -108,7 +108,9 @@ module Postal
rescue BadRequest
# We couldn't read a proper HTTP request, disconnect the client
rescue => e
Raven.capture_exception(e)
if defined?(Raven)
Raven.capture_exception(e)
end
ensure
@socket.close rescue nil
@raw_socket.close rescue nil

عرض الملف

@@ -37,7 +37,9 @@ module Postal
rescue => e
# Somethign else went wrong. We don't want to stop the image loading though because
# this is our problem. Log this exception though.
Raven.capture_exception(e)
if defined?(Raven)
Raven.capture_exception(e)
end
end
source_image = request.params['src']
if source_image.nil?

عرض الملف

@@ -25,7 +25,9 @@ module Postal
rescue IO::WaitReadable, Errno::EINTR
# Never mind, guess the client went away
rescue => e
Raven.capture_exception(e)
if defined?(Raven)
Raven.capture_exception(e)
end
client_io.close rescue nil
end
end

عرض الملف

@@ -51,7 +51,9 @@ module Postal
if Rails.env.development?
raise
else
Raven.capture_exception(e)
if defined?(Raven)
Raven.capture_exception(e)
end
@actioned = false
@tracked_links = 0
@tracked_images = 0

عرض الملف

@@ -170,7 +170,9 @@ module Postal
safe_rset
rescue => e
log "#{e.class}: #{e.message}"
Raven.capture_exception(e, :extra => {:log_id => @log_id, :server_id => message.server.id, :message_id => message.id})
if defined?(Raven)
Raven.capture_exception(e, :extra => {:log_id => @log_id, :server_id => message.server.id, :message_id => message.id})
end
result.type = 'SoftFail'
result.retry = true
result.details = "An error occurred while sending the message to #{destination_host_description}"

عرض الملف

@@ -115,7 +115,9 @@ module Postal
clients[new_io] = client
@epoll.add(new_io, Epoll::IN|Epoll::PRI|Epoll::HUP)
rescue => e
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
if defined?(Raven)
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
end
logger.error "An error occurred while accepting a new client."
logger.error "#{e.class}: #{e.message}"
e.backtrace.each do |line|
@@ -192,7 +194,9 @@ module Postal
end
rescue => e
client_id = client ? client.id : '------'
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
if defined?(Raven)
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
end
logger.error "[#{client_id}] An error occurred while processing data from a client."
logger.error "[#{client_id}] #{e.class}: #{e.message}"
e.backtrace.each do |line|
@@ -281,7 +285,9 @@ module Postal
end
end
rescue => e
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
if defined?(Raven)
Raven.capture_exception(e, :extra => {:log_id => (client.id rescue nil)})
end
logger.error "An error occurred while handling a client."
logger.error "#{e.class}: #{e.message}"
e.backtrace.each do |line|

عرض الملف

@@ -52,7 +52,9 @@ module Postal
klass = message['class_name'].constantize.new(message['id'], message['params'])
klass.perform
rescue => e
Raven.capture_exception(e, :extra => {:job_id => message['id']})
if defined?(Raven)
Raven.capture_exception(e, :extra => {:job_id => message['id']})
end
logger.warn "[#{message['id']}] \e[31m#{e.class}: #{e.message}\e[0m"
e.backtrace.each do |line|
logger.warn "[#{message['id']}] " + line