Skip to content

refactor: Refactor error in DataType#36

Merged
Aitozi merged 6 commits into
apache:mainfrom
XuQianJin-Stars:type-error
Aug 4, 2024
Merged

refactor: Refactor error in DataType#36
Aitozi merged 6 commits into
apache:mainfrom
XuQianJin-Stars:type-error

Conversation

@XuQianJin-Stars

Copy link
Copy Markdown
Contributor

link: #32

Comment thread crates/paimon/src/error.rs Outdated
}

#[derive(Debug, Snafu)]
pub enum DataTypeError {

Copy link
Copy Markdown
Member

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.

@Aitozi Aitozi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment.

pub fn with_nullable(nullable: bool, length: usize) -> Result<Self, Error> {
if !(Self::MIN_LENGTH..=Self::MAX_LENGTH).contains(&length) {
return Err("Character string length must be between 1 and 255 (both inclusive).");
return DataTypeInvalidSnafu {

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, make sense

@Aitozi Aitozi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THanks

@Aitozi Aitozi merged commit e86c828 into apache:main Aug 4, 2024
@XuQianJin-Stars XuQianJin-Stars deleted the type-error branch September 6, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants