Skip to content

Commit

Permalink
Remove thiserror from bevy_animation (#15780)
Browse files Browse the repository at this point in the history
# Objective

- Contributes to #15460

## Solution

- Removed `thiserror` from `bevy_animation`
  • Loading branch information
bushrat011899 authored Oct 9, 2024
1 parent 6f8f70b commit 814f8ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
6 changes: 5 additions & 1 deletion crates/bevy_animation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ petgraph = { version = "0.6", features = ["serde-1"] }
ron = "0.8"
serde = "1"
blake3 = { version = "1.0" }
thiserror = "1"
derive_more = { version = "1", default-features = false, features = [
"error",
"from",
"display",
] }
thread_local = "1"
uuid = { version = "1.7", features = ["v4"] }
smallvec = "1"
Expand Down
11 changes: 5 additions & 6 deletions crates/bevy_animation/src/gltf_curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy_math::{
vec4, Quat, Vec4, VectorSpace,
};
use bevy_reflect::Reflect;
use thiserror::Error;
use derive_more::derive::{Display, Error, From};

/// A keyframe-defined curve that "interpolates" by stepping at `t = 1.0` to the next keyframe.
#[derive(Debug, Clone, Reflect)]
Expand Down Expand Up @@ -318,20 +318,19 @@ where
}

/// An error indicating that a multisampling keyframe curve could not be constructed.
#[derive(Debug, Error)]
#[error("unable to construct a curve using this data")]
#[derive(Debug, Error, Display, From)]
#[display("unable to construct a curve using this data")]
pub enum WideKeyframeCurveError {
/// The number of given values was not divisible by a multiple of the number of keyframes.
#[error("number of values ({values_given}) is not divisible by {divisor}")]
#[display("number of values ({values_given}) is not divisible by {divisor}")]
LengthMismatch {
/// The number of values given.
values_given: usize,
/// The number that `values_given` was supposed to be divisible by.
divisor: usize,
},

/// An error was returned by the internal core constructor.
CoreError(#[from] ChunkedUnevenCoreError),
CoreError(ChunkedUnevenCoreError),
}

impl<T> WideCubicKeyframeCurve<T> {
Expand Down
24 changes: 9 additions & 15 deletions crates/bevy_animation/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use bevy_ecs::{
};
use bevy_reflect::{prelude::ReflectDefault, Reflect, ReflectSerialize};
use bevy_utils::HashMap;
use derive_more::derive::{Display, Error, From};
use petgraph::{
graph::{DiGraph, NodeIndex},
Direction,
};
use ron::de::SpannedError;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use thiserror::Error;

use crate::{AnimationClip, AnimationTargetId};

Expand Down Expand Up @@ -126,16 +126,10 @@ pub struct AnimationGraph {
}

/// A [`Handle`] to the [`AnimationGraph`] to be used by the [`AnimationPlayer`](crate::AnimationPlayer) on the same entity.
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq)]
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
#[reflect(Component, Default)]
pub struct AnimationGraphHandle(pub Handle<AnimationGraph>);

impl From<Handle<AnimationGraph>> for AnimationGraphHandle {
fn from(handle: Handle<AnimationGraph>) -> Self {
Self(handle)
}
}

impl From<AnimationGraphHandle> for AssetId<AnimationGraph> {
fn from(handle: AnimationGraphHandle) -> Self {
handle.id()
Expand Down Expand Up @@ -230,18 +224,18 @@ pub struct AnimationGraphAssetLoader;

/// Various errors that can occur when serializing or deserializing animation
/// graphs to and from RON, respectively.
#[derive(Error, Debug)]
#[derive(Error, Display, Debug, From)]
pub enum AnimationGraphLoadError {
/// An I/O error occurred.
#[error("I/O")]
Io(#[from] io::Error),
#[display("I/O")]
Io(io::Error),
/// An error occurred in RON serialization or deserialization.
#[error("RON serialization")]
Ron(#[from] ron::Error),
#[display("RON serialization")]
Ron(ron::Error),
/// An error occurred in RON deserialization, and the location of the error
/// is supplied.
#[error("RON serialization")]
SpannedRon(#[from] SpannedError),
#[display("RON serialization")]
SpannedRon(SpannedError),
}

/// Acceleration structures for animation graphs that allows Bevy to evaluate
Expand Down

0 comments on commit 814f8ec

Please sign in to comment.