mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(tools): classify expected input and timeout errors, not bugs (#539)
crop/merge-pdf/csv bad input -> ToolInputError/InputValidationError (expected, 4xx); ffmpeg timeout -> operational SafeError. Internal v2-only guards stay plain Errors.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { markToolInputError } from "@snapotter/shared";
|
||||
import { markToolInputError, SafeError } from "@snapotter/shared";
|
||||
import { resolveFfmpeg } from "./binaries.js";
|
||||
import { type FfmpegProgress, parseProgressBlock } from "./progress.js";
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function runFfmpeg(args: string[], opts: RunFfmpegOptions = {}): Pr
|
||||
const timeoutMs = opts.timeoutMs;
|
||||
const timer = timeoutMs
|
||||
? setTimeout(() => {
|
||||
fail(new Error(`ffmpeg timed out after ${Math.round(timeoutMs / 1000)}s`));
|
||||
fail(new SafeError("ffmpeg timed out", { kind: "operational", code: "timeout" }));
|
||||
}, timeoutMs)
|
||||
: undefined;
|
||||
const onAbort = () => fail(new Error("Canceled"));
|
||||
|
||||
Reference in New Issue
Block a user