MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / parseExecError

Method parseExecError

services/cloud-agent-next/src/kilo/client.ts:308–351  ·  view source on GitHub ↗
(
    result: { exitCode: number; stdout: string; stderr: string },
    method: string,
    path: string,
    timeoutSeconds: number,
    httpStatus: number,
    responseBody: string
  )

Source from the content-addressed store, hash-verified

306 }
307
308 private parseExecError(
309 result: { exitCode: number; stdout: string; stderr: string },
310 method: string,
311 path: string,
312 timeoutSeconds: number,
313 httpStatus: number,
314 responseBody: string
315 ): KiloClientError {
316 const { exitCode, stderr } = result;
317
318 if (exitCode === 28) {
319 return new KiloTimeoutError(`Request timed out: ${method} ${path}`, timeoutSeconds * 1000);
320 }
321
322 if (exitCode === 22) {
323 let errorMessage = `HTTP ${httpStatus}: ${method} ${path}`;
324
325 try {
326 const errorBody = JSON.parse(responseBody) as unknown;
327 if (errorBody && typeof errorBody === 'object' && 'message' in errorBody) {
328 const msg = (errorBody as Record<string, unknown>).message;
329 if (typeof msg === 'string' && msg) {
330 errorMessage = `${errorMessage} - ${msg}`;
331 }
332 }
333 } catch {
334 if (responseBody && responseBody.length < 200) {
335 errorMessage = `${errorMessage} - ${responseBody}`;
336 }
337 }
338
339 return new KiloApiError(errorMessage, httpStatus, responseBody);
340 }
341
342 if (exitCode === 7) {
343 return new KiloServerNotReadyError(
344 `Connection refused: ${method} ${path} - is the server running on port ${this.port}?`
345 );
346 }
347
348 return new KiloClientError(
349 `curl failed (exit ${exitCode}): ${method} ${path} - ${stderr || responseBody}`
350 );
351 }
352
353 private validateMessageId(messageId: string): void {
354 if (!messageId.startsWith('msg')) {

Callers 2

callMethod · 0.95
client.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected