Ir al contenido

Swallowed Exception (ARCH2151)

Esta página aún no está disponible en tu idioma.

Key python.logging.swallowed-exception · Severity warning · Category logging

Handlers that catch and silently discard an exception (returning None/False or a default) hide failures. Unlike empty blocks they have a body, yet still provide no diagnostic information.

def load_config(path):
try:
return parse(path)
except Exception:
return None
import logging
logger = logging.getLogger(__name__)
def load_config(path):
try:
return parse(path)
except Exception:
logger.exception("Failed to load config: %s", path)
raise

Log the exception and re-raise where possible; do not silently return a fallback.