bevyengine/bevy · error · ChunkedUnevenCoreError
Could not create a ChunkedUnevenCore
Error message
Could not create a ChunkedUnevenCore
What it means
ChunkedUnevenCoreError is the umbrella error for ChunkedUnevenCore::new and ChunkedUnevenCore::new_width_inferred. The enum carries four concrete variants (ZeroWidth, NotEnoughSamples, MismatchedLengths, NonDivisibleLengths); this top-level text appears when the error is displayed without matching a variant, hiding which check failed. ChunkedUnevenCore stores vector-valued samples ('width' values per time) interpolated at uneven times.
Source
Thrown at crates/bevy_math/src/curve/cores.rs:485
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
pub struct ChunkedUnevenCore<T> {
/// The times, one for each sample.
///
/// # Invariants
/// This must always have a length of at least 2, be sorted, and have no duplicated or
/// non-finite times.
pub times: Vec<f32>,
/// The values that are used in sampling. Each width-worth of these correspond to a single sample.
///
/// # Invariants
/// The length of this vector must always be some fixed integer multiple of that of `times`.
pub values: Vec<T>,
}
/// An error that indicates that a [`ChunkedUnevenCore`] could not be formed.
#[derive(Debug, Error)]
#[error("Could not create a ChunkedUnevenCore")]
pub enum ChunkedUnevenCoreError {
/// The width of a `ChunkedUnevenCore` cannot be zero.
#[error("Chunk width must be at least 1")]
ZeroWidth,
/// At least two sample times are necessary to interpolate in `ChunkedUnevenCore`.
#[error(
"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided"
)]
NotEnoughSamples {
/// The number of samples that were provided.
samples: usize,
},
/// The length of the value buffer is supposed to be the `width` times the number of samples.
#[error("Expected {expected} total values based on width, but {actual} were provided")]
MismatchedLengths {
/// The expected length of the value buffer.View on GitHub (pinned to 396ca72708)
Solutions
- Match on the variant to learn the failed invariant: ZeroWidth, NotEnoughSamples, MismatchedLengths, or NonDivisibleLengths.
- Log with {:?} to keep the variant payload.
- Prefer new() over new_width_inferred — it validates more and gives the clearer MismatchedLengths error.
Example fix
// before
let core = ChunkedUnevenCore::new(times, values, width).map_err(|e| log::error!("core failed: {e}"))?; // generic
// after
let core = match ChunkedUnevenCore::new(times, values, width) {
Ok(core) => core,
Err(e @ (ChunkedUnevenCoreError::ZeroWidth
| ChunkedUnevenCoreError::NotEnoughSamples { .. }
| ChunkedUnevenCoreError::MismatchedLengths { .. }
| ChunkedUnevenCoreError::NonDivisibleLengths { .. })) => {
log::error!("chunked core rejected: {e:?}");
return;
}
}; Defensive patterns
Strategy: try-catch
Try / catch
match ChunkedUnevenCore::new(times, values, width) {
Ok(core) => core,
Err(e) => {
error!("chunked core rejected: {e:?}"); // variant + payload stay visible
return Ok(());
}
} Prevention
- Always format ChunkedUnevenCoreError with {:?} or match variants; never plain {e}.
- Prefer new(width explicit) over new_width_inferred for better error specificity.
- Route all chunked-core construction through one helper with variant-level logging.
When it happens
Trigger: Any failing ChunkedUnevenCore::new(times, values, width) or new_width_inferred(times, values) call whose error is then formatted with {} (e.g. through anyhow) so only the umbrella message is printed.
Common situations: Building curves whose samples are vectors/matrices (e.g. multi-channel animation data) and logging failures generically in a plugin or asset loader.
Related errors
- Could not construct an EvenCore
- Could not construct an UnevenCore
- Not enough data to build curve: needed at least {expected} c
- Need at least two samples to create an EvenCore, but {sample
- Cannot create an EvenCore over an unbounded domain
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/f721a6d27495756a.
Report an issue: GitHub.