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

Remove some DataErrorKind variants #5041

Merged
merged 5 commits into from
Jun 12, 2024
Merged

Conversation

robertbastian
Copy link
Member

No description provided.

@@ -386,7 +386,7 @@ where
DataPayloadInner::Yoke(yoke) => yoke.try_into_yokeable().ok(),
DataPayloadInner::StaticRef(_) => None,
}
.ok_or(DataErrorKind::InvalidState.with_str_context("try_unwrap_owned"))
.ok_or(DataError::custom("DataPayload not owned"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Make this function return Option.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will duplicate the error in the two call sites in any.rs

@robertbastian robertbastian requested a review from sffc June 12, 2024 08:55
@robertbastian robertbastian requested a review from a team as a code owner June 12, 2024 09:01
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

This PR gets rid of two errors:

  • KeyLocaleSyntax: replaces it with locale parse error. Seems good.
  • InvalidState: replaces it with DataError::custom. Not great; we should avoid DataError::custom coming from the core crate.

It would be nice to get rid of InvalidState via some other mechanism, but replacing it with DataError::custom seems like a regression.

@robertbastian
Copy link
Member Author

Well, it gets rid of the one usage of InvalidState, which requires a custom error message to express why the state is invalid. An error is always some kind of invalid state of the program, so I don't consider this variant useful.

@robertbastian robertbastian requested a review from sffc June 12, 2024 09:10
@robertbastian
Copy link
Member Author

Note that deserialization, in the core crate, also returns custom errors. Downcasting Any is not that different.

@sffc
Copy link
Member

sffc commented Jun 12, 2024

Note that deserialization, in the core crate, also returns custom errors. Downcasting Any is not that different.

Ok

@robertbastian robertbastian merged commit 4a94e63 into unicode-org:main Jun 12, 2024
28 checks passed
@robertbastian robertbastian deleted the errsp branch June 12, 2024 10:23
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.

2 participants