-
Notifications
You must be signed in to change notification settings - Fork 410
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
refactor(bindings/zig): add errors handler and module test #2381
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @kassane! Generally looks good. Coments inline.
c.OPENDAL_ALREADY_EXISTS => error.AlreadyExists, | ||
c.OPENDAL_RATE_LIMITED => error.RateLimited, | ||
c.OPENDAL_IS_SAME_FILE => error.IsSameFile, | ||
else => c.OPENDAL_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we map all unknown error to Unexpected
at least for Java bindings. Maybe here is a full conversion - cc @Xuanwo @Ji-Xinyou this can be first handled in C bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible:
Method 1 (unwrap style)
- else => c.OPENDAL_ERROR,
+ else => unreachable,
Method 2
- else => c.OPENDAL_ERROR,
+ else => @panic(str),
Method 3
- else => c.OPENDAL_ERROR,
+ else => @compileError(str),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible:
Method 1 (unwrap style)
- else => c.OPENDAL_ERROR, + else => unreachable,Method 2
- else => c.OPENDAL_ERROR, + else => @panic(str),Method 3
- else => c.OPENDAL_ERROR, + else => @compilerError(str),
I personally prefer compilerError one. I was trying to do that in Rust, but rustc does not support that 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
#2381 (comment) can be a further discussion on error handling policy. I tend to keep the behavior the same with the Rust lib, while @Xuanwo suggest to fallback to Unexpected here #2276 (comment).
Merging... As an under development binding I'd prefer unblock our contributors. Thank you @kassane! |
cc: @tisonkun @Xuanwo