Aller au contenu

Exception Not Logged With Object (ARCH6159)

Ce contenu n’est pas encore disponible dans votre langue.

Key ruby.logging.exception-not-logged · Severity warning · Category logging

Logging only a fixed message inside a rescue drops the exception object and its stack trace. The most valuable debugging information is lost.

def sync
remote.pull
rescue => e
Rails.logger.error("Sync failed")
end
def sync
remote.pull
rescue => e
Rails.logger.error("Sync failed", exception: e)
end

Pass the exception object (including its stack trace) to the log call, not just a message string.