fix(federation): carry error body on HttpError so Reset-cleanup owns-spaces copy reaches the UI

Also narrow SanitizedPeer.needsAttentionReason to the shared union.
This commit is contained in:
Jannis Braun
2026-07-02 02:19:13 +02:00
parent 493deefc64
commit 43d1dad1d7
4 changed files with 33 additions and 21 deletions
+4 -2
View File
@@ -84,10 +84,12 @@ export class RateLimitError extends Error {
export class HttpError extends Error {
readonly status: number;
constructor(status: number, message: string) {
readonly body?: unknown;
constructor(status: number, message: string, body?: unknown) {
super(message);
this.name = 'HttpError';
this.status = status;
this.body = body;
}
}
@@ -369,7 +371,7 @@ export class BackspaceApiClient {
throw new RateLimitError(retryAfter);
}
const error = await response.json().catch(() => ({ error: 'Request failed' }));
throw new HttpError(response.status, (error as { error: string }).error || `HTTP ${response.status}`);
throw new HttpError(response.status, (error as { error?: string }).error || `HTTP ${response.status}`, error);
}
return response.json() as Promise<T>;