bevy/crates/bevy_render/src
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
..
batching Use EntityHashMap<Entity, T> for render world entity storage for better performance (#9903) 2023-09-27 08:28:28 +00:00
camera Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
color Remove useless single tuples and trailing commas (#9720) 2023-09-08 21:46:54 +00:00
mesh Import the second UV map if present in glTF files. (#9992) 2023-10-02 21:07:03 +00:00
primitives Add a method to compute a bounding box enclosing a set of points (#9630) 2023-08-31 01:33:13 +00:00
render_graph Fix the clippy::explicit_iter_loop lint (#9834) 2023-09-19 03:35:22 +00:00
render_phase Replaced parking_lot with std::sync (#9545) 2023-10-02 12:44:34 +00:00
render_resource Removed anyhow (#10003) 2023-10-06 07:20:13 +00:00
renderer ignore time channel error (#9981) 2023-10-01 07:55:17 +00:00
texture Removed anyhow (#10003) 2023-10-06 07:20:13 +00:00
view Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
extract_component.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
extract_param.rs Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
extract_resource.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
globals.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
globals.wgsl Refactor Globals and View structs into separate shaders (#7512) 2023-02-11 17:55:18 +00:00
gpu_component_array_buffer.rs Reorder render sets, refactor bevy_sprite to take advantage (#9236) 2023-08-27 14:33:49 +00:00
instance_index.wgsl Work around naga/wgpu WGSL instance_index -> GLSL gl_InstanceID bug on WebGL2 (#9383) 2023-08-09 18:38:45 +00:00
lib.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
maths.wgsl Use instancing for sprites (#9597) 2023-09-02 18:03:19 +00:00
pipelined_rendering.rs Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
render_asset.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
settings.rs Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
spatial_bundle.rs Improve SpatialBundle docs (#9673) 2023-09-02 23:44:12 +00:00