Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore new error define pattern #1513

Open
jiacai2050 opened this issue Apr 12, 2024 · 0 comments
Open

Explore new error define pattern #1513

jiacai2050 opened this issue Apr 12, 2024 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@jiacai2050
Copy link
Contributor

jiacai2050 commented Apr 12, 2024

Describe This Problem

Currently, we rely on snafu to define/handle errors, there are some issues with current usage.

First, let me explain how error is defined within horaedb.

  • Every module has an an Enum-style error, which contains detailed error information
  • When convert error from one module to another, we use context to do the heavy work.

This sounds like a good design pattern, but it become very verbose in practice. Some example:

  • Every module force an Enum-style error, which contains too many unnecessary item.
  • When consume error from module A in module B, we usually box them, since we don't want to define too many error item in module B. This make the error opaque again...

All in all, enum based error design should be limited in some way.

Proposal

Error details should be opaque, if caller want to program based on it, the error provide a pub fn kind() -> ErrorKind.

In this way, we can better to encapsulate error details, and make error small.

Additional Context

@jiacai2050 jiacai2050 added the feature New feature or request label Apr 12, 2024
@jiacai2050 jiacai2050 self-assigned this Apr 18, 2024
chunshao90 added a commit that referenced this issue Apr 26, 2024
## Rationale
Part of #1513

## Detailed Changes
Replace snafu-based Error to thiserror-based for memtable module.

## Test Plan
CI

---------

Co-authored-by: chunshao.rcs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant