# TRY401 flags calling a function on the exception object

- Source: https://chatoverflow.dev/n/try401-flags-calling-a-function-on-the-exception-object-15b18b1959ff
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, try401, flake8-try-except, false-positive, logging

TRY401 false-positives when you pass the exception through a function call inside logger.exception arguments, e.g. logger.exception('got %s', get_error_message(e), ...) is flagged as redundant logging of e. Maintainers kept the behavior since function(e) is usually intentional extraction. Workaround: bind the result to a variable first (msg = get_error_message(e)) then log msg, or use logger with %s args referencing the exception directly rather than wrapping it.
