Files
fusion/packages/core/src/retry-storm-error.ts
Fusion 831e4969e9 feat(FN-4398): complete Step 2 — add retry summary and retry storm types
Fusion-Task-Id: FN-4398
Fusion-Task-Lineage: 8b898b2e-3468-4fa7-8546-b8f6ba52cf46
2026-05-14 15:25:08 -07:00

37 lines
901 B
TypeScript

import type { RetrySummary } from "./types.js";
export class RetryStormError extends Error {
readonly category: string;
readonly total: number;
readonly cap: number;
readonly breakdown: RetrySummary;
constructor({ category, total, cap, breakdown }: { category: string; total: number; cap: number; breakdown: RetrySummary }) {
super(`Retry storm: ${total} retries exceeds cap ${cap} (top category: ${category})`);
this.name = "RetryStormError";
this.category = category;
this.total = total;
this.cap = cap;
this.breakdown = breakdown;
}
}
export function serializeRetryStormError(err: RetryStormError): {
type: "RetryStormError";
category: string;
total: number;
cap: number;
breakdown: RetrySummary;
} {
return {
type: "RetryStormError",
category: err.category,
total: err.total,
cap: err.cap,
breakdown: err.breakdown,
};
}