Files
mtusi2026lab7/scripts/openobserve-response.ts
T
rey eb1b5c7b84
Skeleton contracts / contracts (pull_request) Canceled after 0s
Prepare verified laboratory 7 implementation and evidence
2026-11-17 17:32:06 +03:00

11 lines
315 B
TypeScript

export function parseOpenObserveResponse(status: number, body: string) {
let data: unknown;
try {
data = body.length ? JSON.parse(body) : null;
} catch {
if (status >= 400) return { status, data: null };
throw new Error(`OPENOBSERVE_HTTP_${status}_INVALID_JSON`);
}
return { status, data };
}