Add core Error to InvalidDirectionError (#17820)
# Objective Fixes #17761 ## Solution - Added core error to InvalidDirectionError ## Testing - Did you test these changes? If so, how? - An added test that pulls in anyhow as a dev dependency to ensure the conversion is accounted for in creation via From - Are there any parts that need more testing? - I'm unsure but probably not due to being a trivial change - How can other people (reviewers) test your changes? Is there anything specific they need to know? - I did not try a fully built version of Bevy. Relied purely on tests. - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? - Only windows --------- Co-authored-by: Chanceler Shaffer <cshaffer2@lululemon.com> Co-authored-by: Chanceler Shaffer <chancelershaffer@lululemon.com>
This commit is contained in:
parent
d76c782f39
commit
cb628516d1
@ -15,14 +15,19 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||
#[cfg(all(debug_assertions, feature = "std"))]
|
||||
use std::eprintln;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// An error indicating that a direction is invalid.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Error)]
|
||||
pub enum InvalidDirectionError {
|
||||
/// The length of the direction vector is zero or very close to zero.
|
||||
#[error("The length of the direction vector is zero or very close to zero")]
|
||||
Zero,
|
||||
/// The length of the direction vector is `std::f32::INFINITY`.
|
||||
#[error("The length of the direction vector is `std::f32::INFINITY`")]
|
||||
Infinite,
|
||||
/// The length of the direction vector is `NaN`.
|
||||
#[error("The length of the direction vector is `NaN`")]
|
||||
NaN,
|
||||
}
|
||||
|
||||
@ -41,15 +46,6 @@ impl InvalidDirectionError {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for InvalidDirectionError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Direction can not be zero (or very close to zero), or non-finite."
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that a vector with the given squared length is normalized.
|
||||
///
|
||||
/// Warns for small error with a length threshold of approximately `1e-4`,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user