nikivdev/code · error

Selection out of range

Error message

Selection out of range

What it means

Error "Selection out of range" thrown in nikivdev/code.

Source

Thrown at src/env.rs:2204

        if selected.is_empty() {
            return Ok(None);
        }
        let id = selected.split('\t').next().unwrap_or(selected);
        return Ok(templates.iter().copied().find(|t| t.id == id));
    }

    println!("Available templates:");
    for (idx, template) in templates.iter().enumerate() {
        println!("  {}. {} ({})", idx + 1, template.title, template.key);
    }
    println!();
    let selection = prompt_line("Select a template number (blank to cancel): ")?;
    let Some(selection) = selection else {
        return Ok(None);
    };
    let idx: usize = selection.trim().parse().context("Invalid selection")?;
    if idx == 0 || idx > templates.len() {
        bail!("Selection out of range");
    }
    Ok(Some(templates[idx - 1]))
}

fn ensure_env_login() -> Result<()> {
    let auth = load_auth_config()?;
    if auth.token.is_some() {
        return Ok(());
    }

    if !std::io::stdin().is_terminal() {
        bail!("Not logged in. Run `f env login` first.");
    }

    if prompt_confirm("Not logged in. Run `f env login` now? (y/N): ")? {
        login()?;
        return Ok(());
    }

View on GitHub (pinned to a747e741ae)

When it happens

Trigger: Thrown at src/env.rs:2204 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/fc2fe177ea923274. Report an issue: GitHub.