Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadAssetBytesError::Io exposes failing path #10450

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use ron::error::SpannedError;
use serde::{Deserialize, Serialize};
use std::{
any::{Any, TypeId},
path::Path,
path::{Path, PathBuf},
};
use thiserror::Error;

Expand Down Expand Up @@ -438,7 +438,13 @@ impl<'a> LoadContext<'a> {
Default::default()
};
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);
Ok(bytes)
}
Expand Down Expand Up @@ -553,8 +559,12 @@ pub enum ReadAssetBytesError {
#[error(transparent)]
MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError),
/// Encountered an I/O error while loading an asset.
#[error("Encountered an io error while loading asset: {0}")]
Io(#[from] std::io::Error),
#[error("Encountered an io error while loading asset at "{path}": {source}")]
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.")]
MissingAssetHash,
}
Loading