(args: {
res: Response;
protocol: AIRouterProtocol;
stream: boolean;
statusCode: number;
message: string;
type: string;
})
| 1306 | } |
| 1307 | |
| 1308 | function 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 | |
| 1334 | function writeAIRouterStreamError( |
| 1335 | res: Response, |
no test coverage detected