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

EventLoopError::ExitFailure(code) and PumpStatus::Exit(code) shouldn't use error codes #3059

Open
daxpedda opened this issue Aug 28, 2023 · 3 comments

Comments

@daxpedda
Copy link
Member

After #3056, we should probably not use error codes anymore.

All uses of EventLoopError::ExitFailure(i32) could return EventLoopError::Os(OsError) instead. PumpStatus::Exit(i32) could probably be PumpStatus::Exit(Result<(), OsError>) instead, unless we want to add another variant for that.

@kchibisov
Copy link
Member

Yeah, having exit code is not a good idea, it's better to propagate error and have a dedicated exit method, though, some may desire a way to exit event loop with their error somehow, or somehow indicate that loop has terminated.

@madsmtm
Copy link
Member

madsmtm commented Aug 29, 2023

But are they exiting the event loop with an error to communicate it to the operating system? Because if so, then they can just do:

let mut error_exit_code: Option<i32> = None;
event_loop.run(|event, elwt| {
    // On some error event:
    error_exit_code = Some(1);
    elwt.exit()
})?;

if let Some(exit_code) = error_exit_code {
    return exit_code;
} else {
    return 0;
}

@kchibisov
Copy link
Member

Hm, yeah, they can sort of stash like that error, that's true and then just propagate it... Then I guess it's fine...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants