added more options to sound buffer load error

This commit is contained in:
Dmitry
2021-07-30 22:14:09 +03:00
parent 81c7e8ba8f
commit 4c9ff0a555
2 changed files with 10 additions and 14 deletions
+3
View File
@@ -112,7 +112,10 @@ impl Seek for DataSource {
/// An error that can occur during loading of sound buffer.
#[derive(Debug)]
pub enum SoundBufferResourceLoadError {
/// A format is not supported.
UnsupportedFormat,
/// File load error.
Io(FileLoadError),
}
define_new_resource!(
+7 -14
View File
@@ -113,21 +113,11 @@ impl Default for ResourceManagerState {
}
/// See module docs.
#[derive(Clone)]
#[derive(Clone, Visit)]
pub struct ResourceManager {
state: Option<Arc<Mutex<ResourceManagerState>>>,
}
impl Visit for ResourceManager {
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult {
visitor.enter_region(name)?;
self.state.visit("State", visitor)?;
visitor.leave_region()
}
}
/// Allows you to define a set of defaults for every imported texture.
#[derive(Clone)]
pub struct TextureImportOptions {
@@ -303,7 +293,7 @@ async fn load_sound_buffer(resource: SoundBufferResource, path: PathBuf, stream:
resource.state().commit(ResourceState::Ok(sound_buffer));
}
Err(_e) => {
Err(_) => {
Log::writeln(
MessageKind::Error,
format!("Unable to load sound buffer from {:?}!", path),
@@ -317,11 +307,14 @@ async fn load_sound_buffer(resource: SoundBufferResource, path: PathBuf, stream:
}
}
Err(e) => {
Log::writeln(MessageKind::Error, format!("Invalid data source: {:?}", e));
Log::writeln(
MessageKind::Error,
format!("Invalid data source for sound buffer: {:?}", e),
);
resource.state().commit(ResourceState::LoadError {
path: path.clone(),
error: Some(Arc::new(SoundBufferResourceLoadError::UnsupportedFormat)),
error: Some(Arc::new(SoundBufferResourceLoadError::Io(e))),
})
}
}