def handle_server_errors(func):
    """
    Decorator to catch internal server errors, print the traceback,
    and return a standardized error response.
    """
    @wraps(func)
    async def async_wrapper(*args, **kwargs):
        try:
            if inspect.iscoroutinefunction(func):
                return await func(*args, **kwargs)
            else:
                return func(*args, **kwargs)
        except Exception as e:
            tb = traceback.extract_tb(e.__traceback__)
            file_path = tb[-1].filename
            if "Upsonic/src/" in file_path:
                file_path = file_path.split("Upsonic/src/")[1]
            line_number = tb[-1].lineno
            traceback.print_exc()
            return {"result": {"status_code": 500, "detail": f"Error processing Call request in {file_path} at line {line_number}: {str(e)}"}, "status_code": 500}

    @wraps(func)
    def sync_wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            tb = traceback.extract_tb(e.__traceback__)
            file_path = tb[-1].filename
            if "Upsonic/src/" in file_path:
                file_path = file_path.split("Upsonic/src/")[1]
            line_number = tb[-1].lineno
            traceback.print_exc()
            return {"result": {"status_code": 500, "detail": f"Error processing Call request in {file_path} at line {line_number}: {str(e)}"}, "status_code": 500}

    return async_wrapper if inspect.iscoroutinefunction(func) else sync_wrapper

    Decorator to catch internal server errors, print the traceback,
    and return a standardized error response.
    
src/upsonic/server/api.py