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.
Incorrect
Section titled “Incorrect”def sync remote.pullrescue => e Rails.logger.error("Sync failed")endCorrect
Section titled “Correct”def sync remote.pullrescue => e Rails.logger.error("Sync failed", exception: e)endPass the exception object (including its stack trace) to the log call, not just a message string.