Improve error handling when reading server favicon

This commit is contained in:
timvisee 2024-03-16 12:50:32 +01:00
parent 6e6d098cf1
commit c311313ecb
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172

View File

@ -281,15 +281,10 @@ async fn server_favicon(config: &Config) -> String {
} }
// Read icon data // Read icon data
let data = match fs::read(path).await.map_err(|err| { let data = fs::read(path).await.unwrap_or_else(|err| {
error!(target: "lazymc", "Failed to read favicon from {}: {}", SERVER_ICON_FILE, err); error!(target: "lazymc::status", "Failed to read favicon from {}, using default: {err}", SERVER_ICON_FILE);
}) { favicon::default_favicon().into_bytes()
Ok(data) => data, });
Err(err) => {
error!(target: "lazymc::status", "Failed to load server icon from disk, using default: {:?}", err);
return favicon::default_favicon();
}
};
favicon::encode_favicon(&data) favicon::encode_favicon(&data)
} }