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

Trickle up errors instead of directly logging #825

Closed
Keksoj opened this issue Nov 8, 2022 · 1 comment
Closed

Trickle up errors instead of directly logging #825

Keksoj opened this issue Nov 8, 2022 · 1 comment
Assignees
Milestone

Comments

@Keksoj
Copy link
Member

Keksoj commented Nov 8, 2022

As discovered in this Pull Request:

Errors are too often logged in the middle of low-level functions, when they should rather get trickled up and logged by the logic calling them.

A good example is in command/src/channel.rs:

sozu/command/src/channel.rs

Lines 119 to 132 in 68e3859

pub fn run(&mut self) {
let interest = self.interest & self.readiness;
if interest.is_readable() {
let _ = self.readable().map_err(|e| {
error!("error reading from channel: {:?}", e);
});
}
if interest.is_writable() {
let _ = self.writable().map_err(|e| {
error!("error writing to channel: {:?}", e);
});
}

This should rather return an anyhow::Result<()> with context, to be handled downstream.

Feel free to comment below on where this change should be applied (or not applied), with github permalinks. Also, quote this issue in ongoing pull requests.

@Keksoj
Copy link
Member Author

Keksoj commented Apr 5, 2023

It seems enough for now. It has gotten too far, even. In the future, we may prefer to use custom Errors in each module and use thiserror instead of anyhow.

See #910

@Keksoj Keksoj closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant