-
Notifications
You must be signed in to change notification settings - Fork 594
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
feat(batch): ensure user-facing context is always present for external system errors #18982
Merged
+49
−35
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kwannoel
changed the title
feat(batch): add
feat(batch): add Oct 17, 2024
ExternalSystemError
variantExternalSystemError
variant to enforce context
kwannoel
changed the title
feat(batch): add
feat(batch): ensure user-facing context is always present for external system errors
Oct 17, 2024
ExternalSystemError
variant to enforce context
BugenZhao
reviewed
Oct 18, 2024
Macro expansion #[derive(::thiserror::Error, ::std::fmt::Debug)]
#[error(transparent)]
pub struct BatchExternalSystemError
(#[from]
#[backtrace] ::anyhow::Error);
impl BatchExternalSystemError
{
/// Unwrap the newtype to get the inner [` anyhow::Error `] .
pub fn into_inner(self) -> ::anyhow::Error {
self.0
}
/// Get the type name of the inner error.
pub fn variant_name(&self) -> &'static str {
if self.0.downcast_ref::<tokio_postgres::Error>().is_some() {
return "tokio_postgres::Error";
}
if self.0.downcast_ref::<iceberg::Error>().is_some() {
return "iceberg::Error";
}
if self.0.downcast_ref::<ParquetError>().is_some() {
return "ParquetError";
}
return "connector_error";
}
}
impl From<tokio_postgres::Error> for BatchExternalSystemError
{
fn from(error: tokio_postgres::Error) -> Self {
Self(::anyhow::Error::new(error).context("Postgres error"))
}
}
impl From<iceberg::Error> for BatchExternalSystemError
{
fn from(error: iceberg::Error) -> Self {
Self(::anyhow::Error::new(error).context("Iceberg error"))
}
}
impl From<ParquetError> for BatchExternalSystemError
{
fn from(error: ParquetError) -> Self {
Self(::anyhow::Error::new(error).context("Parquet error"
))
}
}
impl From<tokio_postgres::Error> for BatchError {
fn from(error: tokio_postgres::Error) -> Self {
BatchError::ExternalSystemError(BatchExternalSystemError::from(error))
}
}
impl From<iceberg::Error> for BatchError {
fn from(error: iceberg::Error) -> Self {
BatchError::ExternalSystemError(BatchExternalSystemError::from(error))
}
}
impl From<ParquetError> for BatchError {
fn from(error: ParquetError) -> Self {
BatchError::ExternalSystemError(BatchExternalSystemError::from(error))
}
} |
BugenZhao
approved these changes
Oct 18, 2024
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
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Oct 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Closes #18860
This PR adds a new macro
def_anyhow_variant
. The semantics of it is to construct a newtype error (same asdef_anyhow_newtype
), and also implement theFrom
trait for each variant of the newtype to the parent error, which the newtype is a variant of.Using this, we create the
BatchExternalSystemError
, and also allow types which are variants of it to be cast intoBatchError
, whichExternalSystemError
is a variant of.Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.