flxzt/rnote · error

SplitOrder try_from:: () for value failed

Error message

SplitOrder try_from::<u32>() for value {} failed

What it means

This error is raised in SplitOrder::try_from (crates/rnote-compose/src/splitorder.rs) when converting a raw u32 into the SplitOrder enum via num_traits::FromPrimitive::from_u32. SplitOrder only has two discriminants (RowMajor=0, ColumnMajor=1), so any value outside 0..=1 fails the generic FromPrimitive lookup and the ok_or_else guard wraps the None into an anyhow error. It typically fires when deserializing a persisted split order or parsing user-supplied numeric input that is out of range or corrupted.

Solutions

  1. Set the split order value to a supported number (check the SplitOrder enum variants in crates/rnote-compose/src/splitorder.rs)
  2. Update rnote to a version that knows the newer variant if the value came from a newer file
  3. Sanitize/clamp config values to valid variants before passing them to the engine

Example fix

// before
"split_order": 7
// after
"split_order": 0
Defensive patterns

Strategy: validation

Validate before calling

const SPLIT_ORDER_VARIANTS: u32 = 2; // adjust to the enum's variant count
if value >= SPLIT_ORDER_VARIANTS {
    eprintln!("split order {} out of range", value);
}

Type guard

fn is_valid_split_order(v: u32) -> bool {
    SplitOrder::try_from(v).is_ok()
}

Try / catch

match SplitOrder::try_from(value) {
    Err(e) if e.to_string().contains("SplitOrder try_from") => {
        eprintln!("Unsupported split order value {}; using default", value);
        SplitOrder::default()
    }
    other => other,
}

Prevention

When it happens

Trigger: Deserializing or converting an out-of-range u32 (e.g. from a config value or file format field) into SplitOrder, where the value is not one of the enumerated orderings.

Common situations: Hand-edited config with an unsupported split-order number; a file written by a newer rnote version using an added variant that this build doesn't know.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/1a98f1f8f316d2a3. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-compose/src/splitorder.rs:50

impl std::fmt::Display for SplitOrder {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                SplitOrder::RowMajor => "horizontal-first",
                SplitOrder::ColumnMajor => "vertical-first",
            }
        )
    }
}

impl TryFrom<u32> for SplitOrder {
    type Error = anyhow::Error;

    fn try_from(value: u32) -> Result<Self, Self::Error> {
        num_traits::FromPrimitive::from_u32(value).ok_or_else(|| {
            anyhow::anyhow!("SplitOrder try_from::<u32>() for value {} failed", value)
        })
    }
}

View on GitHub (pinned to bbc5354502)