diff --git a/crates/bevy_image/src/dds.rs b/crates/bevy_image/src/dds.rs index 4ba311377d..f146f07c71 100644 --- a/crates/bevy_image/src/dds.rs +++ b/crates/bevy_image/src/dds.rs @@ -1,3 +1,5 @@ +//! [DirectDraw Surface](https://en.wikipedia.org/wiki/DirectDraw_Surface) functionality. + #[cfg(debug_assertions)] use bevy_utils::warn_once; use ddsfile::{Caps2, D3DFormat, Dds, DxgiFormat}; @@ -16,7 +18,8 @@ pub fn dds_buffer_to_image( is_srgb: bool, ) -> Result { let mut cursor = Cursor::new(buffer); - let dds = Dds::read(&mut cursor).expect("Failed to parse DDS file"); + let dds = Dds::read(&mut cursor) + .map_err(|error| TextureError::InvalidData(format!("Failed to parse DDS file: {error}")))?; let texture_format = dds_format_to_texture_format(&dds, is_srgb)?; if !supported_compressed_formats.supports(texture_format) { return Err(TextureError::UnsupportedTextureFormat(format!(