mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-05 04:42:55 +00:00
fix(agents): centralize failover status parsing
This commit is contained in:
@@ -77,6 +77,8 @@ describe("failover-error", () => {
|
||||
}),
|
||||
).toBe("billing");
|
||||
expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit");
|
||||
expect(resolveFailoverReasonFromError({ statusCode: "+429" })).toBe("rate_limit");
|
||||
expect(resolveFailoverReasonFromError({ statusCode: "0x1ad" })).toBeNull();
|
||||
expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth");
|
||||
expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout");
|
||||
expect(resolveFailoverReasonFromError({ status: 410 })).toBe("timeout");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { readErrorName } from "../infra/errors.js";
|
||||
import { parseStrictNonNegativeInteger } from "../shared/number-coercion.js";
|
||||
import {
|
||||
classifyFailoverSignal,
|
||||
inferSignalStatus,
|
||||
@@ -132,8 +133,8 @@ function readDirectStatusCode(err: unknown): number | undefined {
|
||||
if (typeof candidate === "number") {
|
||||
return candidate;
|
||||
}
|
||||
if (typeof candidate === "string" && /^\d+$/.test(candidate)) {
|
||||
return Number(candidate);
|
||||
if (typeof candidate === "string") {
|
||||
return parseStrictNonNegativeInteger(candidate);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user