MCPcopy
hub / github.com/msgbyte/tianji / writeAIRouterRuntimeErrorResponse

Function writeAIRouterRuntimeErrorResponse

src/server/model/aiRouter.ts:1308–1332  ·  view source on GitHub ↗
(args: {
  res: Response;
  protocol: AIRouterProtocol;
  stream: boolean;
  statusCode: number;
  message: string;
  type: string;
})

Source from the content-addressed store, hash-verified

1306}
1307
1308function writeAIRouterRuntimeErrorResponse(args: {
1309 res: Response;
1310 protocol: AIRouterProtocol;
1311 stream: boolean;
1312 statusCode: number;
1313 message: string;
1314 type: string;
1315}) {
1316 if (args.stream || args.res.headersSent) {
1317 writeAIRouterStreamError(
1318 args.res,
1319 args.protocol,
1320 args.message,
1321 args.type
1322 );
1323 return;
1324 }
1325
1326 args.res.status(args.statusCode).json({
1327 error: {
1328 message: args.message,
1329 type: args.type,
1330 },
1331 });
1332}
1333
1334function writeAIRouterStreamError(
1335 res: Response,

Callers 1

Calls 3

writeAIRouterStreamErrorFunction · 0.85
statusMethod · 0.80
jsonMethod · 0.65

Tested by

no test coverage detected