refactor(bindings/zig): add errors handler and module test#2381
refactor(bindings/zig): add errors handler and module test#2381tisonkun merged 4 commits intoapache:mainfrom kassane:zig-errorhandler
Conversation
| 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.
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.
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.
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.
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