Log And Rethrow Duplication (ARCH6166)
Esta página aún no está disponible en tu idioma.
Key ruby.logging.log-and-rethrow · Severity warning · Category logging
Logging an exception and then rethrowing it in the same handler produces duplicate log entries when it is logged again higher in the stack. The same error gets reported multiple times.
Incorrect
Section titled “Incorrect”def import(file) parse(file)rescue ParseError => e Rails.logger.error("Import failed", exception: e) raiseendCorrect
Section titled “Correct”def import(file) parse(file)rescue ParseError raiseendEither log and swallow the exception here, or rethrow without logging and log once at the top boundary.