ZIm/crates/gpui/examples
Kirill Bulatov 16366cf9f2
Use anyhow more idiomatically (#31052)
https://github.com/zed-industries/zed/issues/30972 brought up another
case where our context is not enough to track the actual source of the
issue: we get a general top-level error without inner error.

The reason for this was `.ok_or_else(|| anyhow!("failed to read HEAD
SHA"))?; ` on the top level.

The PR finally reworks the way we use anyhow to reduce such issues (or
at least make it simpler to bubble them up later in a fix).
On top of that, uses a few more anyhow methods for better readability.

* `.ok_or_else(|| anyhow!("..."))`, `map_err` and other similar error
conversion/option reporting cases are replaced with `context` and
`with_context` calls
* in addition to that, various `anyhow!("failed to do ...")` are
stripped with `.context("Doing ...")` messages instead to remove the
parasitic `failed to` text
* `anyhow::ensure!` is used instead of `if ... { return Err(...); }`
calls
* `anyhow::bail!` is used instead of `return Err(anyhow!(...));`

Release Notes:

- N/A
2025-05-20 23:06:07 +00:00
..
image chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
svg chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
animation.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
data_table.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
drag_drop.rs gpui: Keep drag cursor style when dragging (#24797) 2025-04-10 23:54:12 +00:00
gif_viewer.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
gradient.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
hello_world.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
image_gallery.rs Use image cache to stop leaking images (#29452) 2025-04-29 19:30:16 +00:00
image_loading.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
input.rs Remove unnecessary result in line shaping (#30721) 2025-05-16 23:48:36 +02:00
on_window_close_quit.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
opacity.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
ownership_post.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
painting.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
pattern.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
set_menus.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
shadow.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
text.rs gpui: Add a standard text example (#30747) 2025-05-16 17:35:44 +02:00
text_layout.rs Revert buggy pr (#28554) 2025-04-10 18:58:36 -06:00
text_wrapper.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
uniform_list.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
window.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
window_positioning.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
window_shadow.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00