From 573fc3087530b9bdbeea98cd7e8768d5016fa0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Thu, 27 May 2021 04:22:48 +0200 Subject: [PATCH 1/2] log errors when loading textures from a gltf file --- crates/bevy_gltf/src/loader.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 6c80c0b999643..8e18d98aaf728 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -4,6 +4,7 @@ use bevy_asset::{ }; use bevy_core::Name; use bevy_ecs::world::World; +use bevy_log::warn; use bevy_math::Mat4; use bevy_pbr::prelude::{PbrBundle, StandardMaterial}; use bevy_render::{ @@ -262,7 +263,26 @@ async fn load_gltf<'a, 'b>( }); }) .into_iter() - .filter_map(|result| result.ok()) + .filter_map(|res| { + if let Err(err) = res.as_ref() { + match err { + GltfError::AssetIoError(error) => { + warn!("Error loading GLTF texture: {}", error) + } + GltfError::ImageError(error) => { + warn!("Error loading GLTF texture, maybe you're missing a feature for the file format: {}", error) + } + GltfError::InvalidImageMimeType(error) => { + warn!("Error loading GLTF texture: {}", error) + } + GltfError::Base64Decode(error) => { + warn!("Error loading GLTF texture: {}", error) + } + _ => (), + } + } + res.ok() + }) .for_each(|(texture, label)| { load_context.set_labeled_asset(&label, LoadedAsset::new(texture)); }); From ff24239d309b9dd0acecabb5589a98d0e6209209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Thu, 27 May 2021 17:36:55 +0200 Subject: [PATCH 2/2] don't try and be clever with errors --- crates/bevy_gltf/src/loader.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 8e18d98aaf728..efc41b6378333 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -50,7 +50,7 @@ pub enum GltfError { BufferFormatUnsupported, #[error("invalid image mime type: {0}")] InvalidImageMimeType(String), - #[error("{0}")] + #[error("You may need to add the feature for the file format: {0}")] ImageError(#[from] TextureError), #[error("failed to load an asset path: {0}")] AssetIoError(#[from] AssetIoError), @@ -265,21 +265,7 @@ async fn load_gltf<'a, 'b>( .into_iter() .filter_map(|res| { if let Err(err) = res.as_ref() { - match err { - GltfError::AssetIoError(error) => { - warn!("Error loading GLTF texture: {}", error) - } - GltfError::ImageError(error) => { - warn!("Error loading GLTF texture, maybe you're missing a feature for the file format: {}", error) - } - GltfError::InvalidImageMimeType(error) => { - warn!("Error loading GLTF texture: {}", error) - } - GltfError::Base64Decode(error) => { - warn!("Error loading GLTF texture: {}", error) - } - _ => (), - } + warn!("Error loading GLTF texture: {}", err); } res.ok() })