Implement error callback system for simplified error handling - #7
Conversation
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
|
The current implementation differs from my expectations. I want the error callback to be configured globally, not per provider. With a globally configured callback, the CCAP implementation can access and invoke it more conveniently, not limited to provider members. Additionally, some examples in the examples directory currently omit this error callback; please add it to all of them. |
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
I've implemented the global error callback system as requested. The changes include: Global Error Callback Functions:
All Examples Updated:
Thread-Safe Implementation:
The global callback is now accessible from all CCAP implementation code without being limited to specific provider instances. Commit: 425c680 |
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
|
Go on; remove the "global" keyword from your naming, do not use "setGlobalErrorCallback"; use "setErrorCallback" instead. The C interface does the same. @copilot |
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
I've removed the "global" keyword from all error callback function names as requested: C++ Interface:
C Interface:
Updated all header files, implementations, examples, and documentation. The functionality remains exactly the same - only the naming has been simplified. Build verification successful. Commit: d2300cf |
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
This PR transforms the error callback system from per-provider to global configuration, making error handling more convenient and accessible throughout the CCAP implementation as requested in feedback.
Key Changes
Error Callback System
ccap::setErrorCallback()andccap::getErrorCallback()replace per-provider callbacksccap_set_error_callback()for global error handlingSimplified Usage
Before (Per-Provider):
After (Global):
Comprehensive Error Codes
Detailed error codes cover all common scenarios:
NoDeviceFound- No camera device found during discoveryInvalidDevice- Invalid device name or index specifiedDeviceOpenFailed- Camera device open failedDeviceStartFailed- Camera start failedUnsupportedResolution- Requested resolution not supportedUnsupportedPixelFormat- Requested pixel format not supportedFrameCaptureTimeout- Frame capture timeoutFrameCaptureFailed- Frame capture failedBenefits
Convenience
Updated Examples
All desktop examples now demonstrate the global callback approach:
ccap::setErrorCallback()ccap_set_error_callback()Implementation Details
Error Reporting Integration
Thread Safety
Documentation Updates
Testing
This enhancement significantly simplifies error handling setup while providing the same detailed error information, making the library more convenient to use and integrate.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.