Skip to content

Commit

Permalink
Slightly better error message on image load failure
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 14, 2023
1 parent 8d7808f commit 539e657
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,17 @@ impl<'a> Widget for Image<'a> {
if show_spinner {
Spinner::new().paint_at(ui, response.rect);
}
response.on_hover_text(format!("Loading {:?}…", self.uri()))

let uri = self.source.uri().unwrap_or("image");
response.on_hover_text(format!("Loading {uri}…"))
}
}
}
Err(err) => ui
.colored_label(ui.visuals().error_fg_color, "⚠")
.on_hover_text(err.to_string()),
Err(err) => {
let uri = self.source.uri().unwrap_or("image");
ui.colored_label(ui.visuals().error_fg_color, "⚠")
.on_hover_text(format!("Failed loading {uri}: {err}"))
}
}
}
}
Expand Down Expand Up @@ -547,13 +551,13 @@ pub fn texture_load_result_response(
match tlr {
Ok(TexturePoll::Ready { .. }) => response,
Ok(TexturePoll::Pending { .. }) => {
if let Some(uri) = source.uri() {
response.on_hover_text(format!("Loading {uri}…"))
} else {
response.on_hover_text("Loading image…")
}
let uri = source.uri().unwrap_or("image");
response.on_hover_text(format!("Loading {uri}…"))
}
Err(err) => {
let uri = source.uri().unwrap_or("image");
response.on_hover_text(format!("Failed loading {uri}: {err}"))
}
Err(err) => response.on_hover_text(err.to_string()),
}
}

Expand Down

0 comments on commit 539e657

Please sign in to comment.