ReadAssetBytesError::Io  exposes failing path (#10450)
				
					
				
			# Objective Addresses #[10438](https://github.com/bevyengine/bevy/issues/10438) The objective was to include the failing path in the error for the user to see. ## Solution Add a `path` field to the `ReadAssetBytesError::Io` variant to expose the failing path in the error message. ## Migration Guide - The `ReadAssetBytesError::Io` variant now contains two named fields instead of converting from `std::io::Error`. 1. `path`: The requested (failing) path (`PathBuf`) 2. `source`: The source `std::io::Error` --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
		
							parent
							
								
									3c689b9ca8
								
							
						
					
					
						commit
						a2d90a8533
					
				| @ -16,7 +16,7 @@ use ron::error::SpannedError; | |||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| use std::{ | use std::{ | ||||||
|     any::{Any, TypeId}, |     any::{Any, TypeId}, | ||||||
|     path::Path, |     path::{Path, PathBuf}, | ||||||
| }; | }; | ||||||
| use thiserror::Error; | use thiserror::Error; | ||||||
| 
 | 
 | ||||||
| @ -440,7 +440,13 @@ impl<'a> LoadContext<'a> { | |||||||
|             Default::default() |             Default::default() | ||||||
|         }; |         }; | ||||||
|         let mut bytes = Vec::new(); |         let mut bytes = Vec::new(); | ||||||
|         reader.read_to_end(&mut bytes).await?; |         reader | ||||||
|  |             .read_to_end(&mut bytes) | ||||||
|  |             .await | ||||||
|  |             .map_err(|source| ReadAssetBytesError::Io { | ||||||
|  |                 path: path.path().to_path_buf(), | ||||||
|  |                 source, | ||||||
|  |             })?; | ||||||
|         self.loader_dependencies.insert(path.clone_owned(), hash); |         self.loader_dependencies.insert(path.clone_owned(), hash); | ||||||
|         Ok(bytes) |         Ok(bytes) | ||||||
|     } |     } | ||||||
| @ -570,8 +576,12 @@ pub enum ReadAssetBytesError { | |||||||
|     #[error(transparent)] |     #[error(transparent)] | ||||||
|     MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError), |     MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError), | ||||||
|     /// Encountered an I/O error while loading an asset.
 |     /// Encountered an I/O error while loading an asset.
 | ||||||
|     #[error("Encountered an io error while loading asset: {0}")] |     #[error("Encountered an io error while loading asset at `{path}`: {source}")] | ||||||
|     Io(#[from] std::io::Error), |     Io { | ||||||
|  |         path: PathBuf, | ||||||
|  |         #[source] | ||||||
|  |         source: std::io::Error, | ||||||
|  |     }, | ||||||
|     #[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")] |     #[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")] | ||||||
|     MissingAssetHash, |     MissingAssetHash, | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 orph3usLyre
						orph3usLyre