{"file":"client/src/api-error.ts","version":40,"total":49,"from":1,"to":49,"lines":[{"n":1,"text":"// How a call to the server fails: an ApiError, and whether the request ever went out.","atom":"a0","author":"init","version":0},{"n":2,"text":"","atom":"a0","author":"init","version":0},{"n":3,"text":"export class ApiError extends Error {","atom":"a0","author":"init","version":0},{"n":4,"text":"\treadonly status: number | undefined;","atom":"a0","author":"init","version":0},{"n":5,"text":"\t/** The connection never opened, so the request never reached the server (safe to run again). */","atom":"a0","author":"init","version":0},{"n":6,"text":"\treadonly notSent: boolean;","atom":"a0","author":"init","version":0},{"n":7,"text":"\tconstructor(message: string, status?: number, notSent = false) {","atom":"a0","author":"init","version":0},{"n":8,"text":"\t\tsuper(message);","atom":"a0","author":"init","version":0},{"n":9,"text":"\t\tthis.name = \"ApiError\";","atom":"a0","author":"init","version":0},{"n":10,"text":"\t\tthis.status = status;","atom":"a0","author":"init","version":0},{"n":11,"text":"\t\tthis.notSent = notSent;","atom":"a0","author":"init","version":0},{"n":12,"text":"\t}","atom":"a0","author":"init","version":0},{"n":13,"text":"}","atom":"a0","author":"init","version":0},{"n":14,"text":"","atom":"a0","author":"init","version":0},{"n":15,"text":"/** Codes for a connection that never opened: the request never went out. */","atom":"a0","author":"init","version":0},{"n":16,"text":"const NOT_SENT = new Set([","atom":"a0","author":"init","version":0},{"n":17,"text":"\t\"UND_ERR_CONNECT_TIMEOUT\",","atom":"a0","author":"init","version":0},{"n":18,"text":"\t\"ECONNREFUSED\",","atom":"a0","author":"init","version":0},{"n":19,"text":"\t\"ENETUNREACH\",","atom":"a0","author":"init","version":0},{"n":20,"text":"\t\"EHOSTUNREACH\",","atom":"a0","author":"init","version":0},{"n":21,"text":"\t\"ENOTFOUND\",","atom":"a0","author":"init","version":0},{"n":22,"text":"\t\"EAI_AGAIN\",","atom":"a0","author":"init","version":0},{"n":23,"text":"\t\"EADDRNOTAVAIL\",","atom":"a0","author":"init","version":0},{"n":24,"text":"]);","atom":"a0","author":"init","version":0},{"n":25,"text":"","atom":"a0","author":"init","version":0},{"n":26,"text":"/** Whether a fetch failed before its request went out (connect timeout, refused, no route, no DNS answer). */","atom":"a0","author":"init","version":0},{"n":27,"text":"export function neverSent(err: unknown): boolean {","atom":"a0","author":"init","version":0},{"n":28,"text":"\tconst cause = (err as { cause?: { code?: string; errors?: readonly { code?: string }[] } }).cause;","atom":"a0","author":"init","version":0},{"n":29,"text":"\tif (cause === undefined) return false;","atom":"a0","author":"init","version":0},{"n":30,"text":"\tif (NOT_SENT.has(cause.code ?? \"\")) return true;","atom":"a0","author":"init","version":0},{"n":31,"text":"\t// Trying each address in turn (Node's autoSelectFamily) fails with every attempt's error.","atom":"a0","author":"init","version":0},{"n":32,"text":"\treturn (","atom":"a0","author":"init","version":0},{"n":33,"text":"\t\tArray.isArray(cause.errors) &&","atom":"a0","author":"init","version":0},{"n":34,"text":"\t\tcause.errors.length > 0 &&","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\tcause.errors.every((e) => NOT_SENT.has(e.code ?? \"\") || e.code === \"ETIMEDOUT\")","atom":"a0","author":"init","version":0},{"n":36,"text":"\t);","atom":"a0","author":"init","version":0},{"n":37,"text":"}","atom":"a0","author":"init","version":0},{"n":38,"text":"","atom":"a0","author":"init","version":0},{"n":39,"text":"/** The server's `{error: \"sentence\"}` answer, or the start of whatever it sent. */","atom":"a0","author":"init","version":0},{"n":40,"text":"export function errorSentence(body: string): string {","atom":"a0","author":"init","version":0},{"n":41,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":42,"text":"\t\tconst parsed = JSON.parse(body) as { error?: unknown; reason?: unknown };","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\tif (typeof parsed.error === \"string\") return parsed.error;","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\tif (typeof parsed.reason === \"string\") return parsed.reason;","atom":"a0","author":"init","version":0},{"n":45,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t// Not JSON.","atom":"a0","author":"init","version":0},{"n":47,"text":"\t}","atom":"a0","author":"init","version":0},{"n":48,"text":"\treturn body.slice(0, 300);","atom":"a0","author":"init","version":0},{"n":49,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}}]}