mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
Check asset-path existence. Previously App just crashed if not (#345)
* Check asset-path existence. Previously App just crashed if not * rustfmt * Relegated Error-message to ChannelAssetHandler * Removed needless return statement
This commit is contained in:
parent
b718a2063d
commit
93040ef9a0
1 changed files with 12 additions and 5 deletions
|
@ -38,11 +38,18 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_asset(&self, load_request: &LoadRequest) -> Result<TAsset, AssetLoadError> {
|
fn load_asset(&self, load_request: &LoadRequest) -> Result<TAsset, AssetLoadError> {
|
||||||
let mut file = File::open(&load_request.path)?;
|
match File::open(&load_request.path) {
|
||||||
let mut bytes = Vec::new();
|
Ok(mut file) => {
|
||||||
file.read_to_end(&mut bytes)?;
|
let mut bytes = Vec::new();
|
||||||
let asset = self.loader.from_bytes(&load_request.path, bytes)?;
|
file.read_to_end(&mut bytes)?;
|
||||||
Ok(asset)
|
let asset = self.loader.from_bytes(&load_request.path, bytes)?;
|
||||||
|
Ok(asset)
|
||||||
|
}
|
||||||
|
Err(e) => Err(AssetLoadError::Io(std::io::Error::new(
|
||||||
|
e.kind(),
|
||||||
|
format!("{}", load_request.path.display()),
|
||||||
|
))),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue