table-extraction / utils /error_utils.py
jobian's picture
Modular project structure
3ab32c0
raw
history blame contribute delete
380 Bytes
import traceback
from config import IN_SPACES
def safe_err(msg: str, exc: Exception | None = None) -> str:
"""Return error messages based on environment (Spaces vs local)."""
if IN_SPACES:
return f"⚠️ {msg}" + (f" ({type(exc).__name__}: {exc})" if exc else "")
else:
tb = traceback.format_exc() if exc else ""
return f"❌ {msg}\n\n{tb}"