-
Notifications
You must be signed in to change notification settings - Fork 32
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: Refactor error in DataType #36
Conversation
crates/paimon/src/error.rs
Outdated
@@ -38,3 +38,12 @@ pub enum Error { | |||
source: opendal::Error, | |||
}, | |||
} | |||
|
|||
#[derive(Debug, Snafu)] | |||
pub enum DataTypeError { |
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.
Hi, we usually expose only one error in each crate to keep them user-friendly. I will suggest to add DataTypeInvalid
as a new enum in Error
directly. In this way, we can use paimon::Error
everywhere.
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.
Left a minor comment.
if !(Self::MIN_LENGTH..=Self::MAX_LENGTH).contains(&length) { | ||
return Err("Character string length must be between 1 and 255 (both inclusive)."); | ||
return DataTypeInvalidSnafu { |
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.
Can we simplify this by ensure!(length < Self::MIN_LENGTH, DataTypeInvalidSnafu {message: "Binary string length must be at least 1."});
?
The same as below
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.
Can we simplify this by
ensure!(length < Self::MIN_LENGTH, DataTypeInvalidSnafu {message: "Binary string length must be at least 1."});
?The same as below
This simplifies things a bit, but the readability of the code is reduced.
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.
Ok, make sense
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
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
link: #32