-
Notifications
You must be signed in to change notification settings - Fork 3
Add StackError and intergrate into the code #1050
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
Add StackError and intergrate into the code #1050
Conversation
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
@YaroslavLitvinov Is it ready for review or you're still working on it? |
Also, what is an example for It should be possible to keep #[snafu(display("Object store error: {error}"))]
ObjectStore {
#[snafu(source)] // <----- NOTE THIS
error: ObjectStoreError,
#[snafu(implicit)]
location: Location,
}, Then it would be possible to apply |
Ok, I see and surprised it is working in this way. Will update my PR. |
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
SQL Logic Tests Results ❌Coverage by SLT File
Overall: 97/227 (42.7%) |
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
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.
I went though this PR this time diagonally (just skimming mostly) as I dived deeper over the course of previous week.
LGTM as a start - approving the general approach and guidlelines. I prefer not to block this PR with nitpicks, but I assume there will be follow up PRs.
✅ SLT Targeted Testing: No relevant SLT tests found for the changes in this PR. No testing required. |
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.
reapprove
Related to issue #1040 that currently contains a basic description, which will be extended using the principles introduced in this PR.
Improve error handling: Phase 1
(Formerly: WIP Streamline error handling 1st attempt)
This PR :
#[stack_trace_debug]
that is extending our Snafu errorsDraft proposal to be added to Contributing rules
#[snafu(visibility(pub(crate)))]
;Result<>
per crate; Print error stack trace on a crate level Error;#[error_stack_trace::debug]
;#[error_stack_trace::debug]
, rename the field from source to error, and annotate it with#[snafu(source)]
to support context selectors;#[snafu(implicit)] location: Location
;.context()
,build()
,fail()
, andinto_error()
from the generated Snafu types as the standard pattern;.map_err(...)
for error handling is generally considered an anti-pattern;Result<T>
needs to return a specific error, prefer using Snafu context selectors like.context(...)
, which can be chained. Avoid manually constructing Snafu errors;#[snafu(transparent)]
doesn't have own context selector generated (NoWhateverSnafu
generated).Though
transparent
has Into conversion, that called implicitly on?
operation, like here:.context(...)?
Dealing with foreign / non Snafu errors (not derived from
#[error_stack_trace::debug]
)Boxing errors
In case of clippy warning:
clippy::result_large_err
, it may need to Box error. Using Snafu in the proper way, in the wast majority of the cases, doesn't require creating Boxes manually as well as doing boxes conversions.