Background
During PR review #80, @LinZhihao-723 suggested adopting result-style error handling (similar to Rust's Result type) instead of relying on exceptions, particularly for factory functions. The current approach of using factory functions that throw exceptions is not meaningful since constructors can behave similarly.
Benefits
Result-style error handling would allow:
- Forwarding error codes from the core FFI layer more effectively
- More explicit error handling patterns
- Better integration with the underlying CLP core error handling
Challenges
The main challenge identified is mapping such result types to Emscripten's Embind system for JavaScript bindings.
Timing
This enhancement should be implemented after:
- Syncing the latest CLP code into clp-ffi-js
- Completion of the proposed error handling refactoring in the CLP codebase
References
Requested by: @junhaoliao
Background
During PR review #80, @LinZhihao-723 suggested adopting result-style error handling (similar to Rust's Result type) instead of relying on exceptions, particularly for factory functions. The current approach of using factory functions that throw exceptions is not meaningful since constructors can behave similarly.
Benefits
Result-style error handling would allow:
Challenges
The main challenge identified is mapping such result types to Emscripten's Embind system for JavaScript bindings.
Timing
This enhancement should be implemented after:
References
Requested by: @junhaoliao