{"record":{"id":"47fe973b2cbf5724","repo":"bevyengine/bevy","slug":"could-not-construct-an-evencore","errorCode":null,"errorMessage":"Could not construct an EvenCore","messagePattern":"Could not construct an EvenCore","errorType":"exception","errorClass":"EvenCoreError","httpStatus":null,"severity":"error","filePath":"crates/bevy_math/src/curve/cores.rs","lineNumber":140,"sourceCode":"#[cfg_attr(feature = \"bevy_reflect\", derive(Reflect))]\npub struct EvenCore<T> {\n    /// The domain over which the samples are taken, which corresponds to the domain of the curve\n    /// formed by interpolating them.\n    ///\n    /// # Invariants\n    /// This must always be a bounded interval; i.e. its endpoints must be finite.\n    pub domain: Interval,\n\n    /// The samples that are interpolated to extract values.\n    ///\n    /// # Invariants\n    /// This must always have a length of at least 2.\n    pub samples: Vec<T>,\n}\n\n/// An error indicating that an [`EvenCore`] could not be constructed.\n#[derive(Debug, Error)]\n#[error(\"Could not construct an EvenCore\")]\npub enum EvenCoreError {\n    /// Not enough samples were provided.\n    #[error(\"Need at least two samples to create an EvenCore, but {samples} were provided\")]\n    NotEnoughSamples {\n        /// The number of samples that were provided.\n        samples: usize,\n    },\n\n    /// Unbounded domains are not compatible with `EvenCore`.\n    #[error(\"Cannot create an EvenCore over an unbounded domain\")]\n    UnboundedDomain,\n}\n\n#[cfg(feature = \"alloc\")]\nimpl<T> EvenCore<T> {\n    /// Create a new [`EvenCore`] from the specified `domain` and `samples`. The samples are\n    /// regarded to be evenly spaced within the given domain interval, so that the outermost\n    /// samples form the boundary of that interval. An error is returned if there are not at","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_math/src/curve/cores.rs#L122-L158","documentation":"EvenCoreError is the umbrella error returned by EvenCore::new (and APIs that build evenly-sampled curves on top of it, like EvenSampleCurve/SampleCurve constructors). The enum-level message appears when the error is displayed without matching a variant — e.g. logged via {} or converted to a string — while the concrete cause (too few samples or unbounded domain) is in the variant. Check the variants NotEnoughSamples and UnboundedDomain for specifics.","triggerScenarios":"Any call to EvenCore::new(domain, samples), or higher-level constructors that wrap it, failing for either reason; then formatting the error with {} instead of {:?} or matching variants, so only the umbrella text is visible.","commonSituations":"Logging curve-construction failures in a plugin and only seeing the generic message; chaining errors with anyhow/eyre where the enum Display is what gets printed.","solutions":["Match on the variant to get the real cause: NotEnoughSamples { samples } vs UnboundedDomain.","Use {:?} (Debug) in logs — it prints the variant and its payload.","Fix the underlying condition per the variant's documentation (see the sibling error entries)."],"exampleFix":"// before\nlet curve = EvenCore::new(domain, samples).map_err(|e| format!(\"curve failed: {e}\"))?; // \"Could not construct an EvenCore\"\n\n// after\nlet core = match EvenCore::new(domain, samples) {\n    Ok(core) => core,\n    Err(EvenCoreError::NotEnoughSamples { samples }) => {\n        return Err(format!(\"need >= 2 samples, got {samples}\").into());\n    }\n    Err(EvenCoreError::UnboundedDomain) => {\n        return Err(\"domain must be bounded\".into());\n    }\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match EvenCore::new(domain, samples) {\n    Ok(core) => core,\n    Err(e @ (EvenCoreError::NotEnoughSamples { .. } | EvenCoreError::UnboundedDomain)) => {\n        warn!(\"even core rejected: {e:?}\");\n        return Ok(());\n    }\n}","preventionTips":["Always match EvenCoreError variants instead of displaying the enum, so the real cause is never hidden.","In logs use {:?} for these error enums.","Wrap curve construction in one place with a single, well-logged match so every failure mode is observable."],"tags":["rust","bevy","math","curve","runtime","error-matching"],"backgroundTag":"curve-core-construction-failed","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}