improve error message when asset type hasn't beed added to app (#1487)
Error message noticed in #1475 When an asset type hasn't been added to the app but a load was attempted, the error message wasn't helpful: ``` thread 'IO Task Pool (0)' panicked at 'Failed to find AssetLifecycle for label Some("Mesh0/Primitive0"), which has an asset type 8ecbac0f-f545-4473-ad43-e1f4243af51e. Are you sure that is a registered asset type?', /.cargo/git/checkouts/bevy-f7ffde730c324c74/89a41bc/crates/bevy_asset/src/asset_server.rs:435:17 ``` means that ```rust .add_asset::<bevy::render::prelude::Mesh>() ``` needs to be added. * type name was not given, only UUID, which may make it hard to identify type across bevy/plugins * instruction were not helpful as the `register_asset_type` method is not public new error message: ``` thread 'IO Task Pool (1)' panicked at 'Failed to find AssetLifecycle for label 'Some("Mesh0/Primitive0")', which has an asset type "bevy_render::mesh::mesh::Mesh" (UUID 8ecbac0f-f545-4473-ad43-e1f4243af51e). Are you sure this asset type has been added to your app builder?', /bevy/crates/bevy_asset/src/asset_server.rs:435:17 ```
This commit is contained in:
parent
aa81aaf3fa
commit
86e2fc53d0
@ -435,7 +435,13 @@ impl AssetServer {
|
|||||||
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
|
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
|
||||||
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
|
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
|
||||||
} else {
|
} else {
|
||||||
panic!("Failed to find AssetLifecycle for label {:?}, which has an asset type {:?}. Are you sure that is a registered asset type?", label, asset_value.type_uuid());
|
panic!(
|
||||||
|
"Failed to find AssetLifecycle for label '{:?}', which has an asset type {} (UUID {:?}). \
|
||||||
|
Are you sure this asset type has been added to your app builder?",
|
||||||
|
label,
|
||||||
|
asset_value.type_name(),
|
||||||
|
asset_value.type_uuid(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ pub trait TypeUuid {
|
|||||||
|
|
||||||
pub trait TypeUuidDynamic {
|
pub trait TypeUuidDynamic {
|
||||||
fn type_uuid(&self) -> Uuid;
|
fn type_uuid(&self) -> Uuid;
|
||||||
|
fn type_name(&self) -> &'static str;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> TypeUuidDynamic for T
|
impl<T> TypeUuidDynamic for T
|
||||||
@ -16,4 +17,8 @@ where
|
|||||||
fn type_uuid(&self) -> Uuid {
|
fn type_uuid(&self) -> Uuid {
|
||||||
Self::TYPE_UUID
|
Self::TYPE_UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn type_name(&self) -> &'static str {
|
||||||
|
std::any::type_name::<Self>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user