mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Remove thiserror
from bevy_scene
(#15764)
# Objective - Contributes to #15460 ## Solution - Removed `thiserror` from `bevy_scene`
This commit is contained in:
parent
c9e41ef552
commit
b50f2ec334
4 changed files with 24 additions and 31 deletions
|
@ -29,7 +29,11 @@ bevy_render = { path = "../bevy_render", version = "0.15.0-dev", optional = true
|
|||
# other
|
||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
uuid = { version = "1.1", features = ["v4"] }
|
||||
thiserror = "1.0"
|
||||
derive_more = { version = "1", default-features = false, features = [
|
||||
"error",
|
||||
"from",
|
||||
"display",
|
||||
] }
|
||||
|
||||
[dev-dependencies]
|
||||
postcard = { version = "1.0", features = ["alloc"] }
|
||||
|
|
|
@ -3,6 +3,7 @@ use bevy_derive::{Deref, DerefMut};
|
|||
use bevy_ecs::component::Component;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_transform::components::Transform;
|
||||
use derive_more::derive::From;
|
||||
|
||||
#[cfg(feature = "bevy_render")]
|
||||
use bevy_render::view::visibility::Visibility;
|
||||
|
@ -11,26 +12,14 @@ use crate::{DynamicScene, Scene};
|
|||
|
||||
/// Adding this component will spawn the scene as a child of that entity.
|
||||
/// Once it's spawned, the entity will have a [`SceneInstance`](crate::SceneInstance) component.
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[require(Transform)]
|
||||
#[cfg_attr(feature = "bevy_render", require(Visibility))]
|
||||
pub struct SceneRoot(pub Handle<Scene>);
|
||||
|
||||
impl From<Handle<Scene>> for SceneRoot {
|
||||
fn from(handle: Handle<Scene>) -> Self {
|
||||
Self(handle)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adding this component will spawn the scene as a child of that entity.
|
||||
/// Once it's spawned, the entity will have a [`SceneInstance`](crate::SceneInstance) component.
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq)]
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[require(Transform)]
|
||||
#[cfg_attr(feature = "bevy_render", require(Visibility))]
|
||||
pub struct DynamicSceneRoot(pub Handle<DynamicScene>);
|
||||
|
||||
impl From<Handle<DynamicScene>> for DynamicSceneRoot {
|
||||
fn from(handle: Handle<DynamicScene>) -> Self {
|
||||
Self(handle)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ use bevy_ecs::{
|
|||
world::{FromWorld, World},
|
||||
};
|
||||
use bevy_reflect::TypeRegistryArc;
|
||||
use derive_more::derive::{Display, Error, From};
|
||||
#[cfg(feature = "serialize")]
|
||||
use serde::de::DeserializeSeed;
|
||||
use thiserror::Error;
|
||||
|
||||
/// Asset loader for a Bevy dynamic scene (`.scn` / `.scn.ron`).
|
||||
///
|
||||
|
@ -30,14 +30,14 @@ impl FromWorld for SceneLoader {
|
|||
|
||||
/// Possible errors that can be produced by [`SceneLoader`]
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Error)]
|
||||
#[derive(Debug, Error, Display, From)]
|
||||
pub enum SceneLoaderError {
|
||||
/// An [IO Error](std::io::Error)
|
||||
#[error("Error while trying to read the scene file: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
#[display("Error while trying to read the scene file: {_0}")]
|
||||
Io(std::io::Error),
|
||||
/// A [RON Error](ron::error::SpannedError)
|
||||
#[error("Could not parse RON: {0}")]
|
||||
RonSpannedError(#[from] ron::error::SpannedError),
|
||||
#[display("Could not parse RON: {_0}")]
|
||||
RonSpannedError(ron::error::SpannedError),
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
|
|
|
@ -8,8 +8,8 @@ use bevy_ecs::{
|
|||
world::{Command, Mut, World},
|
||||
};
|
||||
use bevy_hierarchy::{AddChild, BuildChildren, DespawnRecursiveExt, Parent};
|
||||
use bevy_utils::{tracing::error, HashMap, HashSet};
|
||||
use thiserror::Error;
|
||||
use bevy_utils::{HashMap, HashSet};
|
||||
use derive_more::derive::{Display, Error};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Triggered on a scene's parent entity when [`crate::SceneInstance`] becomes ready to use.
|
||||
|
@ -72,22 +72,22 @@ pub struct SceneSpawner {
|
|||
}
|
||||
|
||||
/// Errors that can occur when spawning a scene.
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(Error, Display, Debug)]
|
||||
pub enum SceneSpawnError {
|
||||
/// Scene contains an unregistered component type.
|
||||
#[error("scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type")]
|
||||
#[display("scene contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type")]
|
||||
UnregisteredComponent {
|
||||
/// Type of the unregistered component.
|
||||
type_path: String,
|
||||
},
|
||||
/// Scene contains an unregistered resource type.
|
||||
#[error("scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type")]
|
||||
#[display("scene contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type")]
|
||||
UnregisteredResource {
|
||||
/// Type of the unregistered resource.
|
||||
type_path: String,
|
||||
},
|
||||
/// Scene contains an unregistered type.
|
||||
#[error(
|
||||
#[display(
|
||||
"scene contains the unregistered type `{std_type_name}`. \
|
||||
consider reflecting it with `#[derive(Reflect)]` \
|
||||
and registering the type using `app.register_type::<T>()`"
|
||||
|
@ -97,7 +97,7 @@ pub enum SceneSpawnError {
|
|||
std_type_name: String,
|
||||
},
|
||||
/// Scene contains an unregistered type which has a `TypePath`.
|
||||
#[error(
|
||||
#[display(
|
||||
"scene contains the reflected type `{type_path}` but it was not found in the type registry. \
|
||||
consider registering the type using `app.register_type::<T>()``"
|
||||
)]
|
||||
|
@ -106,19 +106,19 @@ pub enum SceneSpawnError {
|
|||
type_path: String,
|
||||
},
|
||||
/// Scene contains a proxy without a represented type.
|
||||
#[error("scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`.")]
|
||||
#[display("scene contains dynamic type `{type_path}` without a represented type. consider changing this using `set_represented_type`.")]
|
||||
NoRepresentedType {
|
||||
/// The dynamic instance type.
|
||||
type_path: String,
|
||||
},
|
||||
/// Dynamic scene with the given id does not exist.
|
||||
#[error("scene does not exist")]
|
||||
#[display("scene does not exist")]
|
||||
NonExistentScene {
|
||||
/// Id of the non-existent dynamic scene.
|
||||
id: AssetId<DynamicScene>,
|
||||
},
|
||||
/// Scene with the given id does not exist.
|
||||
#[error("scene does not exist")]
|
||||
#[display("scene does not exist")]
|
||||
NonExistentRealScene {
|
||||
/// Id of the non-existent scene.
|
||||
id: AssetId<Scene>,
|
||||
|
|
Loading…
Reference in a new issue