Exception Not Logged With Object (ARCH3159)
Key typescript.logging.exception-not-logged · Severity warning · Category logging
Logging only a static message string inside a catch while dropping the exception object loses the stack trace and error details. Diagnosing the problem becomes nearly impossible.
Incorrect
Section titled “Incorrect”try { await sendEmail(user);} catch (err) { logger.error("failed to send email");}Correct
Section titled “Correct”try { await sendEmail(user);} catch (err) { logger.error("failed to send email", { userId: user.id, err });}Include the exception object (and relevant context) in the log call to preserve the stack trace.