import { NextResponse } from "next/server"; import { WebRequestError } from "yt-dlp-transcript-common/lib/web/pacer"; import { opsFail } from "./_lib"; // A web read's failure as an ops answer: a request the fence or the input // refuses before anything is sent is a 400; an answer from the far side (an // HTTP error, a back-off that ran out, a page that is not text) is a 502. export function webFailure(e: unknown): NextResponse { if (e instanceof WebRequestError) return opsFail(e.message, e.status === null ? 400 : 502); throw e; }