Skip to content

Adopt result-style error handling for factory functions instead of exceptions #89

@coderabbitai

Description

@coderabbitai

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:

  1. Syncing the latest CLP code into clp-ffi-js
  2. Completion of the proposed error handling refactoring in the CLP codebase

References

Requested by: @junhaoliao

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions