Skip to content

Commit

Permalink
Improve error handling when reading server favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
timvisee committed Mar 16, 2024
1 parent 6e6d098 commit c311313
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,10 @@ async fn server_favicon(config: &Config) -> String {
}

// Read icon data
let data = match fs::read(path).await.map_err(|err| {
error!(target: "lazymc", "Failed to read favicon from {}: {}", SERVER_ICON_FILE, err);
}) {
Ok(data) => data,
Err(err) => {
error!(target: "lazymc::status", "Failed to load server icon from disk, using default: {:?}", err);
return favicon::default_favicon();
}
};
let data = fs::read(path).await.unwrap_or_else(|err| {
error!(target: "lazymc::status", "Failed to read favicon from {}, using default: {err}", SERVER_ICON_FILE);
favicon::default_favicon().into_bytes()
});

favicon::encode_favicon(&data)
}

0 comments on commit c311313

Please sign in to comment.