Files
openclaw/ui/src/lib/gateway-errors.ts
Shakker 65e12328aa feat: refactor the Control UI architecture
Refactor the Control UI around route-owned page lifecycle and state while preserving existing behavior and design.

Prepared head SHA: bd51b6fa76
Co-authored-by: Shakker <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
2026-07-04 23:19:38 +01:00

21 lines
939 B
TypeScript

// Control UI shared Gateway error helpers.
import { ConnectErrorDetailCodes } from "../../../packages/gateway-protocol/src/connect-error-details.js";
import { GatewayRequestError, resolveGatewayErrorDetailCode } from "../api/gateway.ts";
export function isMissingOperatorReadScopeError(err: unknown): boolean {
if (!(err instanceof GatewayRequestError)) {
return false;
}
const detailCode = resolveGatewayErrorDetailCode(err);
// AUTH_UNAUTHORIZED is the current server signal for scope failures in RPC responses.
// The message-based branch catches responses that do not include a structured detail code yet.
return (
detailCode === ConnectErrorDetailCodes.AUTH_UNAUTHORIZED ||
err.message.includes("missing scope: operator.read")
);
}
export function formatMissingOperatorReadScopeMessage(feature: string): string {
return `This connection is missing operator.read, so ${feature} cannot be loaded yet.`;
}