Exit codes & errors
Every rereel invocation ends with one of five exit codes. The same numbers are exported as constants and used as RereelError.code in the API.
| Code | Constant | Meaning |
|---|---|---|
0 |
EXIT_OK |
Success (including --help and validate with valid: true). |
1 |
EXIT_FAIL |
The operation ran but its result is wrong: invalid bundle, integrity failure, missing data at run time. Also used for unexpected (non-RereelError) exceptions. |
2 |
EXIT_USAGE |
Bad invocation or bad input files: missing/unknown arguments, non-numeric flags, missing or invalid JSON, invalid configuration. |
3 |
EXIT_DEPENDENCY |
A required external program or template is not installed. |
4 |
EXIT_COMMAND |
An external program or remote service failed. |
When each code occurs
Section titled “When each code occurs”1 — EXIT_FAIL
Section titled “1 — EXIT_FAIL”validatefinished withvalid: false(the report is printed as normal output, not as an error object).hydrate/build: SHA-256 mismatch after download,--offlinewith a missing or stale asset, lock item withouturi, provider did not write the file,local-cacheobject missing.build: rendered chunk has the wrong frame count, composite media part not found, audio file referenced bymix_plan.jsonnot found.- Any unexpected exception (e.g. a JavaScript
TypeErroror filesystem error) →{"status":"error","code":1,"error":"<String(err)>"}.
2 — EXIT_USAGE
Section titled “2 — EXIT_USAGE”- Unknown command (
Unknown command: <cmd>) or patch operation (Unknown patch op: <op>). - Missing positional/required flags (
freeze requires <reel_dir>,cut-retakes requires --input <path>,ripple-shift requires --at-sec and --delta-sec,trim-segment requires --id,swap-asset requires --old and --new, …). - Non-numeric numeric flag (
Flag --fps must be a number: abc). - A required JSON file is missing (
File not found: …) or unparseable (Invalid JSON in …), including the storage config. - Storage configuration problems: unknown provider name (details include
available), unsupported providertype, S3 withoutbucketor credentials, invalids3://URI,commandprovider withoutstoreCommand/resolveCommand, storing via the read-onlyhttpprovider. build: duration not determinable, no template, Remotion entry not found, invalidlocal/storagetemplate ref, composite withoutparts, mix plan without positiveduration_sec.cut-retakes: input not found or duration undetectable.patch trim-segment: narration segment ID not found.
3 — EXIT_DEPENDENCY
Section titled “3 — EXIT_DEPENDENCY”- An executable could not be spawned (
ENOENT):ffmpeg,ffprobe, the Remotion CLI,npm,npx,tar,cp,mv,/bin/sh. Details includecommand. build: abuiltintemplate was not found under$REREEL_TEMPLATES_DIRor~/.samurai/templates/remotion.
4 — EXIT_COMMAND
Section titled “4 — EXIT_COMMAND”- An external process exited non-zero (Remotion render, FFmpeg,
npm ci,tar, astoreCommand/resolveCommand) or timed out. Details includeexitCode, the last 1500 characters ofstderr, and the last 500 characters ofstdout. The message ends with the last stderr line. - S3
PUT/GETor HTTPGETreturned a non-2xx status. storeCommandproduced no URI.resolveCommandproduced no usable file (details includestdout).- Two-pass
loudnormmeasurements could not be parsed.
Error JSON
Section titled “Error JSON”On failure the CLI prints exactly one line to stdout and exits with code:
{ status: "error"; code: number; // same as the process exit code error: string; // human-readable message ...details // RereelError.details spread at the top level (optional)}Examples:
{"status":"error","code":2,"error":"Unknown command: bogus"}{"status":"error","code":2,"error":"Unknown storage provider: r2","available":["local-cache","http"]}{"status":"error","code":4,"error":"Command failed (exit 1): npx remotion render src/index.ts Main -- Error: Composition \"Main\" not found","exitCode":1,"stderr":"…","stdout":""}{"status":"error","code":1,"error":"Missing or mismatched local asset in offline mode: media/bg_1a2b3c4d.png","relPath":"media/bg_1a2b3c4d.png","uri":"cas://1a2b3c4d….png"}Because details keys are spread next to status, code, and error, check status === "error" first and read the extra keys only when present.
Scripting pattern
Section titled “Scripting pattern”out=$(rereel build ./reels/ep01)case $? in 0) echo "$out" | jq -r '.outPath' ;; 2) echo "usage/config problem: $(echo "$out" | jq -r '.error')" >&2 ;; 3) echo "install ffmpeg/remotion first" >&2 ;; *) echo "$out" | jq . >&2 ;;esac