-
Notifications
You must be signed in to change notification settings - Fork 346
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
Fix/return multi errors on create failed #2998
Fix/return multi errors on create failed #2998
Conversation
When container creation fails and triggers a cleanup process that also fails, the original creation error is overwritten by the cleanup error. This change ensures that both the primary creation error and the subsequent cleanup error are captured and reported, providing better visibility into the failure sequence. Signed-off-by: xujihui1985 <[email protected]>
Signed-off-by: xujihui1985 <[email protected]>
@YJDoc2 Hi, would you like to have a look at this PR? |
Hey, this is technically fine, nothing wrong per say ; but I don't like this implementation 😅 I'll try to think on this, and see if I can think of some other way, otherwise approve and merge this in a couple of days. (Bit busy now, probably go over on the weekend) |
I agree with you. The current implementation is too specific to this case, but I haven't found a better way to address it. What I tried was adding a new extension trait for Result<T, E> with an implementation like this:
However, outer is moved in this context unless I clone it, which isn't feasible since outer isn't clonable. |
Hey, so I thought about this -
After thinking, I think we can modify your approach slightly to solve the issues I have with it -
I still don't think this is the most ergonomic way for this, but maybe a step in right direction? As I said this is a very special and specific case where we need to return two errors instead of directly returning after the first. wdyt? Comments and suggestions very welcome :) |
add CreateContainerError to encapsulate both create error and cleanup error, so that caller will understand what happened Signed-off-by: xujihui1985 <[email protected]>
change createContainerError to tuple instead of struct Signed-off-by: xujihui1985 <[email protected]>
Hi @YJDoc2 , I have updated the code according to your advice. |
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! Thanks @xujihui1985 !
Given that you have implemented this change, I think you also agreed with my deign suggestions, but I will wait in case you want to comment anything or suggest any alternatives. Otherwise merge in some time.
Ok, I'm going ahead and merging this. Also in my last comment, typo : deign -> design 😅 |
this PR fix the problem describe in this PR #2997.
When container creation fails and triggers a cleanup process that also fails, the original creation error is overwritten by the cleanup error.This change ensures that both the primary creation error and the subsequent cleanup error are captured and reported, providing better visibility into the failure sequence.