Simplify instance details and clarify diagnostics

This commit is contained in:
2026-10-06 17:42:05 -04:00
parent f4094b7f5d
commit b8cccc5a98
15 changed files with 329 additions and 323 deletions
+3 -2
View File
@@ -52,8 +52,9 @@ export function createLogRefresh(options: Options) {
try {
const response = await request(`/api/servers/${encodeURIComponent(target.server)}/logs/${encodeURIComponent(target.key)}?lines=${target.lines}`,
{ signal: entry.controller.signal, cache: 'no-store' });
const body = await response.json() as LogResponse;
if (!response.ok || !body.ok) throw new Error(body.reason ?? 'Could not refresh log.');
const body = await response.json().catch(() => null) as LogResponse | null;
if (!response.ok || !body?.ok) throw new Error(body?.reason ?? `HTTP ${response.status}: ${body ? 'Log request failed.' : 'Expected a JSON log response.'}`);
if (!Array.isArray(body.lines) || !body.lines.every(line => typeof line === 'string')) throw new Error('Invalid log response: expected an array of lines.');
if (current()) { options.onError(''); options.onData(target.key, body); }
} catch (error) {
if (current() && !entry.controller.signal.aborted) options.onError(error instanceof Error ? error.message : 'Could not refresh log.');