bevy/crates/bevy_render/src/render_resource
Zachary Harrold dd46fd3aee
Removed anyhow (#10003)
# Objective

- Fixes #8140

## Solution

- Added Explicit Error Typing for `AssetLoader` and `AssetSaver`, which
were the last instances of `anyhow` in use across Bevy.

---

## Changelog

- Added an associated type `Error` to `AssetLoader` and `AssetSaver` for
use with the `load` and `save` methods respectively.
- Changed `ErasedAssetLoader` and `ErasedAssetSaver` `load` and `save`
methods to use `Box<dyn Error + Send + Sync + 'static>` to allow for
arbitrary `Error` types from the non-erased trait variants. Note the
strict requirements match the pre-existing requirements around
`anyhow::Error`.

## Migration Guide

- `anyhow` is no longer exported by `bevy_asset`; Add it to your own
project (if required).
- `AssetLoader` and `AssetSaver` have an associated type `Error`; Define
an appropriate error type (e.g., using `thiserror`), or use a pre-made
error type (e.g., `anyhow::Error`). Note that using `anyhow::Error` is a
drop-in replacement.
- `AssetLoaderError` has been removed; Define a new error type, or use
an alternative (e.g., `anyhow::Error`)
- All the first-party `AssetLoader`'s and `AssetSaver`'s now return
relevant (and narrow) error types instead of a single ambiguous type;
Match over the specific error type, or encapsulate (`Box<dyn>`,
`thiserror`, `anyhow`, etc.)

## Notes

A simpler PR to resolve this issue would simply define a Bevy `Error`
type defined as `Box<dyn std::error::Error + Send + Sync + 'static>`,
but I think this type of error handling should be discouraged when
possible. Since only 2 traits required the use of `anyhow`, it isn't a
substantive body of work to solidify these error types, and remove
`anyhow` entirely. End users are still encouraged to use `anyhow` if
that is their preferred error handling style. Arguably, adding the
`Error` associated type gives more freedom to end-users to decide
whether they want more or less explicit error handling (`anyhow` vs
`thiserror`).

As an aside, I didn't perform any testing on Android or WASM. CI passed
locally, but there may be mistakes for those platforms I missed.
2023-10-06 07:20:13 +00:00
..
batched_uniform_buffer.rs Automatic batching/instancing of draw commands (#9685) 2023-09-21 22:12:34 +00:00
bind_group_layout.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
bind_group.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
buffer_vec.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
buffer.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
gpu_array_buffer.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
mod.rs Add GpuArrayBuffer and BatchedUniformBuffer (#8204) 2023-07-21 16:46:56 +00:00
pipeline_cache.rs Replaced parking_lot with std::sync (#9545) 2023-10-02 12:44:34 +00:00
pipeline_specializer.rs added multi-line string formatting (#8350) 2023-04-13 18:00:17 +00:00
pipeline.rs Add push contant config to layout (#7681) 2023-02-17 06:20:16 +00:00
resource_macros.rs remove potential ub in render_resource_wrapper (#7279) 2023-02-06 17:14:00 +00:00
shader.rs Removed anyhow (#10003) 2023-10-06 07:20:13 +00:00
storage_buffer.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
texture.rs Add screenshot api (#7163) 2023-04-19 21:28:42 +00:00
uniform_buffer.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00