MCPcopy Create free account
hub / github.com/HyperInspire/InspireFace / handle_c_api_errors

Function handle_c_api_errors

python/inspireface/modules/exception.py:227–242  ·  view source on GitHub ↗

Decorator for wrapping C API calls

(operation_name: str)

Source from the content-addressed store, hash-verified

225# === Exception handling decorators for special scenarios ===
226
227def handle_c_api_errors(operation_name: str):
228 """Decorator for wrapping C API calls"""
229 def decorator(func):
230 def wrapper(*args, **kwargs):
231 try:
232 return func(*args, **kwargs)
233 except Exception as e:
234 if not isinstance(e, InspireFaceError):
235 # Wrap non-InspireFace exceptions as ProcessingError
236 raise ProcessingError(
237 f"{operation_name}: {str(e)}",
238 context={'original_exception': type(e).__name__}
239 ) from e
240 raise
241 return wrapper
242 return decorator

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected