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
					
				| @ -38,12 +38,19 @@ 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) { | ||||||
|  |             Ok(mut file) => { | ||||||
|                 let mut bytes = Vec::new(); |                 let mut bytes = Vec::new(); | ||||||
|                 file.read_to_end(&mut bytes)?; |                 file.read_to_end(&mut bytes)?; | ||||||
|                 let asset = self.loader.from_bytes(&load_request.path, bytes)?; |                 let asset = self.loader.from_bytes(&load_request.path, bytes)?; | ||||||
|                 Ok(asset) |                 Ok(asset) | ||||||
|             } |             } | ||||||
|  |             Err(e) => Err(AssetLoadError::Io(std::io::Error::new( | ||||||
|  |                 e.kind(), | ||||||
|  |                 format!("{}", load_request.path.display()), | ||||||
|  |             ))), | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<TLoader, TAsset> AssetLoadRequestHandler for ChannelAssetHandler<TLoader, TAsset> | impl<TLoader, TAsset> AssetLoadRequestHandler for ChannelAssetHandler<TLoader, TAsset> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Telzhaak
						Telzhaak