tonhowtf/omniget · error

escolha o spritesheet

Error message

escolha o spritesheet

What it means

Thrown by slice when gather(opts) returns no input files, meaning no spritesheet was selected. slice takes the first gathered file, so an empty list makes slicing impossible and the run aborts with this user-facing message.

Solutions

  1. Set SpriteOptions input to an existing spritesheet file (or a folder/pattern that matches at least one file).
  2. Check gather()'s matching rules (extensions, recursion) and make sure your file qualifies.
  3. Validate the input exists before calling run() and show a file picker when empty.
  4. Handle this error in the UI as a 'choose a file' prompt rather than a crash.

Example fix

// before
let result = image_sprite::run(&opts, &progress); // opts.input empty
// after
if opts.input.as_os_str().is_empty() || !opts.input.exists() {
    return Err(anyhow!("selecione um spritesheet antes de fatiar"));
}
let result = image_sprite::run(&opts, &progress);
Defensive patterns

Strategy: validation

Validate before calling

fn has_input(opts: &SpriteOptions) -> bool {
    let files = gather(opts);
    !files.is_empty()
}
// call run() only if has_input(&opts)

Try / catch

match image_sprite::run(&opts, &progress) {
    Err(e) if e.to_string().contains("escolha o spritesheet") => prompt_file_picker(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling run() with mode "slice" and SpriteOptions whose input path/pattern yields zero files (empty input path, nonexistent folder, pattern matching nothing, or all files filtered out).

Common situations: User forgets to pick a file in the UI; input path points to an empty directory; glob pattern typo; file was moved/deleted before the operation ran.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/6588d3237251d418. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/image_sprite.rs:344

    }
    serde_json::to_string_pretty(&serde_json::json!({
        "frames": serde_json::Value::Object(map),
        "meta": {
            "app": "OmniGet",
            "image": sheet,
            "format": "RGBA8888",
            "size": { "w": w, "h": h },
            "scale": "1"
        }
    }))
    .unwrap_or_else(|_| "{}".into())
}

fn slice(opts: &SpriteOptions, progress: &ProgressFn) -> anyhow::Result<SpriteResult> {
    let files = gather(opts);
    let input = files
        .first()
        .ok_or_else(|| anyhow!("escolha o spritesheet"))?;
    let sheet = image::open(input)
        .map_err(|e| anyhow!("não abri {}: {}", input.display(), e))?
        .to_rgba8();
    let grid = Grid {
        cols: opts.cols,
        rows: opts.rows,
        cell_w: opts.cell_w,
        cell_h: opts.cell_h,
        margin: opts.margin,
        spacing: opts.spacing,
    };
    let cells = grid_cells(sheet.width(), sheet.height(), &grid);
    if cells.is_empty() {
        return Err(anyhow!("a grade não cabe nessa folha"));
    }

    let stem = if opts.name.trim().is_empty() {
        input

View on GitHub (pinned to 8600b91f42)