MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / wrap_api_call

Function wrap_api_call

codewiki/cli/utils/api_errors.py:114–139  ·  view source on GitHub ↗

Wrap an API call with error handling. Args: func: Function to call *args: Positional arguments fail_fast: Whether to raise on error (default: True) context: Optional context for error message **kwargs: Keyword arguments Returns:

(func, *args, fail_fast: bool = True, context: Optional[str] = None, **kwargs)

Source from the content-addressed store, hash-verified

112
113 Args:
114 func: Function to call
115 *args: Positional arguments
116 fail_fast: Whether to raise on error (default: True)
117 context: Optional context for error message
118 **kwargs: Keyword arguments
119
120 Returns:
121 Function result
122
123 Raises:
124 APIError: If API call fails and fail_fast is True
125 """
126 try:
127 return func(*args, **kwargs)
128 except Exception as e:
129 api_error = APIErrorHandler.handle_api_error(e, context=context, fail_fast=fail_fast)
130 if fail_fast:
131 raise api_error
132 else:
133 APIErrorHandler.display_api_error(api_error)
134 return None

Callers

nothing calls this directly

Calls 2

handle_api_errorMethod · 0.80
display_api_errorMethod · 0.80

Tested by

no test coverage detected