Skip to content

Commit 0f369de

Browse files
committed
fix(log): log warn in case of payment required
1 parent 4ea2902 commit 0f369de

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/lib/server/router/endpoint.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,17 @@ export async function makeRouterEndpoint(routerModel: ProcessedModel): Promise<E
240240
return metadataThenStream(gen, toolsCandidate, ROUTER_TOOLS_ROUTE);
241241
} catch (e) {
242242
const { message, statusCode } = extractUpstreamError(e);
243-
logger.error(
244-
{
245-
route: ROUTER_TOOLS_ROUTE,
246-
model: toolsCandidate,
247-
err: message,
248-
...(statusCode && { status: statusCode }),
249-
},
250-
"[router] tools fallback failed"
251-
);
243+
const logData = {
244+
route: ROUTER_TOOLS_ROUTE,
245+
model: toolsCandidate,
246+
err: message,
247+
...(statusCode && { status: statusCode }),
248+
};
249+
if (statusCode === 402) {
250+
logger.warn(logData, "[router] tools fallback failed due to payment required");
251+
} else {
252+
logger.error(logData, "[router] tools fallback failed");
253+
}
252254
throw statusCode ? new HTTPError(message, statusCode) : new Error(message);
253255
}
254256
}

0 commit comments

Comments
 (0)