34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# error_handler.py
|
|
|
|
import logging
|
|
|
|
def handle_general_error(e):
|
|
logging.error(f'An error occurred during the process: {e}')
|
|
# Add any additional error handling logic here
|
|
|
|
def handle_file_not_found_error(e):
|
|
logging.error(f"File not found error: {e}")
|
|
# Add any additional error handling logic here
|
|
|
|
def handle_value_error(e):
|
|
logging.error(f"Value error: {e}")
|
|
# Add any additional error handling logic here
|
|
|
|
def handle_error(error_message):
|
|
logging.error(f"Error: {error_message}")
|
|
|
|
def notify_error(error_message, e=None):
|
|
"""
|
|
Centralized error reporting: logs the error and triggers email notification.
|
|
"""
|
|
full_message = f"{error_message}: {e}" if e else error_message
|
|
logging.error(full_message)
|
|
try:
|
|
from email_utils import handle_error as send_notification
|
|
send_notification(Exception(full_message) if e is None else e)
|
|
except Exception as notify_err:
|
|
logging.error(f"Failed to trigger email notification: {notify_err}")
|
|
|
|
class ClientError(Exception):
|
|
"""Custom exception class for client errors."""
|
|
pass |