-
Notifications
You must be signed in to change notification settings - Fork 7
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
Expect cleanup #29
Expect cleanup #29
Conversation
This is logically equivalent to how it was before - but previously the two Option<_> were implicitly coupled - both Some(_) or None at the same time.
I really like your idea about using |
Yeah, I agree. I'll add There is the alternative of catching the panic and trying to continue execution - |
So is the panic handler the same for all panics? Like would the message be the same? |
There's only one panic handler, but you get panic info, e.g. #[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
exit(1);
} So you can't say "I'm only going to handle panics from except" - they're all just panics either way. But when you display the panic, you get specific info, e.g. a backtrace.
|
Can you change the conversion method you wrote for |
|
I might be dumb but does this PR still need to be merged? I am confused on whether this just turned into a discussion or if it actually is still a PR. |
Of the two changes, one fixes a bug where |
I'll take a look at this later today. |
Looking back at this, was your point essentially that these error types have different meanings in-context, but that |
Yup, exactly. |
In that case, can you make the method names clearer? For instance, |
Not quite sure it's what you had in mind, but it's what I found to work best, though it's a bit at odds with having all custom errors for everything - that would require more verbosity and some trait hackery. I think this should be fine as far as users getting the right information goes. Also, I went with |
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 like the direction you're going with this, but I don't think the implementation fits in with the existing codebase. This is more of a reflection on the oversimplification of error handling in the existing code than it is a critique of your contribution. However, I would like to have a more thorough discussion on the exact ways we are planning to handle errors going forward - and we will change this PR appropriately after that occurs.
P.S. I am aware that my comments may seem a bit pedantic; they were not intended to be so, I just would like to be thorough in my feedback, rather than just saying "fix this" etc.
rush-exec/src/errors.rs
Outdated
WaitingForChild | ||
} | ||
|
||
pub trait IoContextExt { |
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.
This needs to have a clearer name and a description.
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.
Does IoErrorContextExt
seem fine? I tried some other stuff like ConvertIoErrorWithContextExt
but that seems to be getting a bit too long imo.
rush-exec/src/errors.rs
Outdated
} | ||
|
||
pub enum FileContext { | ||
Reading, |
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.
Do you think this would be better as FileRead
or OnFileRead
or something? That one's up to you - just wondering what would allow for the most consistency.
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 think it depends on whether the convention is to qualify it or not - if it's imported with a glob, FileRead
would be better, but if it's qualified, FileContext::Reading
is better. I think importing with a glob makes sense here, so I'll go with that.
rush-exec/src/errors.rs
Outdated
@@ -33,4 +99,7 @@ pub enum ExecutableError { | |||
FailedToParseStdout(String), | |||
#[error("Failed to parse executable stderr: {0}")] | |||
FailedToParseStderr(String), | |||
/// This variant is a fallthrough, and you should generally prefer a more specific/human-readable error | |||
#[error("{0}")] | |||
OtherIoError(#[from] IoError), |
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.
If this is not specific to executables or builtins, it may be worth thinking about either:
- Making a separate error type called
FileSystemError
- Making an upstream error enum (
CommandError
or something) that has aFile
variant
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.
Another thing I forgot to delete 😅
Right now it's basically just spitting out a string, but those concrete errors types are never used. I agree the work in this PR should probably be lifted somewhere higher, but I'm gonna leave that alone pending further discussion.
That makes sense - let's put this on hold until then - I'll respond to your comments then we can leave this alone for a while.
They didn't come across as pedantic - I think it's a pretty normal part of code review. |
Remove a few expects.
history_get
because similarly, if it fails, it's an internal bug. Not that those bugs won't happen, but I think we should probably use something like human_panic or another panic handler/catch (maybe one that lets us continue running).std
is full of panics, and they're gonna happen, so it'd be more robust to take that route.