# Errors, exit codes, and troubleshooting Every message below is a **verbatim real stderr capture** from the pinned CLI (`@firecrawl/anydoc@0.2.4`) run against the committed fixtures in `fixtures/` (and, for resource limits, generated oversized archives). The CLI prints exactly one line to stderr, prefixed `anydoc: `, and never prompts. ## Exit codes | Code | Meaning | Triggers | | --- | --- | --- | | `0` | Success | Normal conversion; `--help`/`--version`; also on **EPIPE** when the downstream pipe closes early (`anydoc big.xlsx \| head`). | | `1` | The document could not be read or converted | Any conversion or IO failure below: missing file, unsupported input, scanned/image-only PDF, malformed archive, encrypted document, resource limit, `-o` pointing at a directory. | | `2` | Usage error | Unknown option, missing input, invalid `--format`, more than one input, an option missing its value, stdin is a terminal. | ## Conversion / IO failures (exit code 1) ### io — the file could not be read ``` anydoc: io error: No such file or directory (os error 2) ``` This is the missing-file case (`to_markdown` path only; stdin and byte APIs have no io error). ### unsupported — unknown format or unconvertible content Unknown content **and** unknown extension (the extension is echoed as given): ``` anydoc: unsupported input: unrecognized file content and extension: unsupported.xyz ``` Verified against `fixtures/unsupported.xyz` (run from the fixture directory, the tail is `unsupported.xyz`; when you pass a longer path, that path is echoed). Recognized format but unconvertible content — a **scanned or image-only PDF** (the CLI detects the page count and that it looks scanned): ``` anydoc: unsupported input: PDF has no extractable text (Scanned, 1 pages): OCR is required ``` Verified against `fixtures/scanned-image-only.pdf`: exit 1, empty stdout. ### unsupported — stdin without a format CSV has no content signature and stdin has no extension, so CSV piped to `-` without `--format csv` fails: ``` anydoc: unsupported input: unrecognized file content: name the format explicitly ``` Fix: add `--format csv` (e.g. `cat data.csv | npx -y @firecrawl/anydoc@0.2.4 - --format csv`). ### malformed — structurally unusable archive An empty (0-byte) `.docx` and a truncated `.docx` both produce: ``` anydoc: malformed document: not a readable zip archive: invalid Zip archive: Could not find EOCD ``` Verified against `fixtures/empty--errors.docx`. Any other structurally broken package surfaces the same class. ### encrypted — password-protected document ``` anydoc: document is encrypted ``` Verified against `fixtures/encrypted--errors.odt`. There is **no password or decryption option** anywhere in the CLI or library — the only fix is an unencrypted copy of the file. ### resourceLimit — fixed safety limits (decompression / nesting / node count) Zip-bomb style DOCX (giant `word/document.xml`): ``` anydoc: resource limit exceeded (max_entry_bytes): word/document.xml declares 201326759 decompressed bytes ``` Image-bomb style DOCX (giant `word/media/image1.png`): ``` anydoc: resource limit exceeded (max_entry_bytes): word/media/image1.png declares 201326592 decompressed bytes ``` The **character-exact prefix** is: ``` anydoc: resource limit exceeded (max_entry_bytes): ``` with a tail naming the offending entry and the declared decompressed size — the tail varies by entry, so match on the prefix. Verified also with a generated 250 MB-entry zip (tail: `word/document.xml declares 250000000 decompressed bytes`). anydoc rejects zip/image bombs via `max_entry_bytes`; conversion is **not streaming**, and the whole entry is checked before use. ### output-is-directory (EISDIR) `-o` pointing at an existing directory fails with exit 1: ``` anydoc: EISDIR: illegal operation on a directory, open '' ``` Verified: `npx -y @firecrawl/anydoc@0.2.4 report.rtf -o /tmp` prints `anydoc: EISDIR: illegal operation on a directory, open '/tmp'` and exits 1. Fix: pass a file path (or a path in a directory that exists); anydoc **does not create directories**. ## Usage errors (exit code 2) All verified verbatim: ``` anydoc: missing input: pass a document path, or - for stdin (see anydoc --help) anydoc: unknown option '--bogus' (see anydoc --help) anydoc: invalid format 'bogus'; expected one of: doc, docx, odt, pdf, ppt, pptx, rtf, epub, xlsx, ods, odp, csv anydoc: one document per invocation: unexpected second input '' anydoc: stdin is a terminal; pipe or redirect a document into anydoc - anydoc: -o requires a value (pattern: `