Reference

Errors and exit codes

One list of failure kinds, the same on every surface. Branch on the kind, log the detail.

Peel 1.4.0 · Snack Studio · Updated

The shape

On the CLI, the C library and the Rust library, a failure has a stable kind and a free-text detail. The kind is the contract: it never changes meaning between releases. The detail is the engine’s own text, for logs and bug reports, and can change at any time.

JSON
{"error": "wrong_password", "detail": "…engine text, for logs…"}
Surface Where the error arrives
CLI With -j or --ndjson-progress, one JSON line on standard error, and the exit code below.
C library Every string-returning call returns the JSON object above instead of its result.
MCP A tool result with isError: true and a plain message such as incorrect password. MCP carries no error kind.
Rust library PeelError, with .kind() returning ErrorKind and .report() serialising the object.

not_enough_space adds two fields, needed and available, both in bytes.

Seeing one

An archive whose names try to climb out of the destination is refused before anything is written:

peel x hostile.zip -o out -j; echo "exit $?"
{"error":"unsafe_entry","detail":"extract hostile.zip: path escape blocked: ../escape.txt"}
exit 13
Real output from peel 1.4.0, recorded 2026-11-26.

A wrong password is its own kind, distinct from a missing one, so a script can ask again instead of giving up:

PEEL_PASSWORD=wrong peel x locked.zip -o out -j; echo "exit $?"
{"error":"wrong_password","detail":"extract locked.zip: incorrect password"}
exit 4
Real output from peel 1.4.0, recorded 2026-11-26.

Every kind

Kind Exit Meaning
password_required 3 The archive is encrypted and no password was given.
wrong_password 4 A password was given and it does not open the archive.
damaged 5 Damaged, truncated, or missing a part.
not_enough_space 6 The destination disk is too full. Adds needed and available.
unsupported 7 Not an archive Rind reads, or a feature it does not support.
permission_denied 8 The system refused the read or the write.
decompression_bomb 9 Unpacks to far more than it could plausibly hold.
too_large 10 Over a size or entry-count limit.
not_found 11 The archive, or the entry asked for, does not exist.
invalid_name 12 An entry name that is absolute or climbs out with ...
unsafe_entry 13 An entry that would land outside the destination, or a link out of it.
already_exists 14 The output exists and the policy says not to replace it.
io 16 Any other input or output failure.
other 1 A failure with no more specific kind.
cancelled — Stopped on request. Library and C library only.
panic — C library only: the engine hit an internal error reading this archive. Nothing unwinds into C.

Exit code 0 is success, 1 is a general failure and 2 is a usage error, such as an unknown flag.

Branching on it

In a shell, the exit code is enough:

TerminalShell
peel x "$archive" -o out -q
case $? in
  0) echo "done" ;;
  3|4) echo "needs the right password" ;;
  5) peel salvage "$archive" -o salvaged ;;
  13) echo "refused: unsafe entry names" ;;
  *) echo "failed" ;;
esac

From any language that runs a process, read the JSON line instead, so a log keeps the detail:

Python
import json, subprocess
r = subprocess.run(["peel", "x", path, "-o", "out", "-j"], capture_output=True, text=True)
if r.returncode != 0:
    err = json.loads(r.stderr.strip().splitlines()[-1])
    if err["error"] == "wrong_password":
        ask_again()
Branch on the kind, never the detail. The detail is written for people and changes between versions; the kind and the exit code do not.