spb/tendril Public
Tendril — web ingestion platform (scrape/crawl/map/search) on macOS Apple Silicon: WebKit fidelity, authenticated pages, deterministic testable extraction. A self-hosted Firecrawl alternative.
JavaScript 82.6%
TypeScript 11.8%
HTML 5.3%
1// author: simon-pierre boucher <contact@spboucher.ai>2import { httpStatusFor, type ErrorCode, type TendrilError } from "@tendril/shared";34export interface ApiErrorBody {5 readonly success: false;6 readonly error: {7 readonly code: ErrorCode;8 readonly message: string;9 readonly details?: Readonly<Record<string, unknown>>;10 };11 readonly requestId: string;12}1314/**15 * The §15 mapping applied at the HTTP boundary — the single place that turns a16 * TendrilError into an HTTP status + response envelope. The status table itself17 * lives in @tendril/shared ERROR_TAXONOMY; this function is its only consumer at18 * the API edge.19 */20export function toApiError(error: TendrilError, requestId: string): { status: number; body: ApiErrorBody } {21 const status = httpStatusFor(error.code);22 const body: ApiErrorBody = {23 success: false,24 error: {25 code: error.code,26 message: error.message,27 ...(error.details !== undefined ? { details: error.details } : {}),28 },29 requestId,30 };31 return { status, body };32}33