carraraig's picture
Hello
8816dfd
raw
history blame contribute delete
678 Bytes
import logging
from typing import Dict, Any
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='[%(asctime)s][%(levelname)s] - %(message)s'
)
logger = logging.getLogger(__name__)
def create_success_response(result: Any) -> Dict[str, Any]:
"""Helper to create a standardized success response."""
return {
"status": "success",
"result": result
}
def handle_exception(e: Exception, operation: str) -> Dict[str, Any]:
"""Helper to standardize error responses."""
logger.exception(f"Error during {operation}: {e}")
return {
"status": "error",
"message": str(e),
"operation": operation
}