(
reply: { send(payload: unknown): unknown },
requestId: string,
err: unknown,
)
| 445 | } |
| 446 | |
| 447 | function sendMappedError( |
| 448 | reply: { send(payload: unknown): unknown }, |
| 449 | requestId: string, |
| 450 | err: unknown, |
| 451 | ): void { |
| 452 | if (err instanceof PromptAlreadyCompletedError) { |
| 453 | reply.send({ |
| 454 | code: ErrorCode.PROMPT_ALREADY_COMPLETED, |
| 455 | msg: err.message, |
| 456 | data: { aborted: false }, |
| 457 | request_id: requestId, |
| 458 | }); |
| 459 | return; |
| 460 | } |
| 461 | if (err instanceof SessionBusyError) { |
| 462 | reply.send({ |
| 463 | code: ErrorCode.SESSION_BUSY, |
| 464 | msg: err.message, |
| 465 | data: null, |
| 466 | request_id: requestId, |
| 467 | details: { active_prompt_id: err.activePromptId }, |
| 468 | }); |
| 469 | return; |
| 470 | } |
| 471 | if (err instanceof PromptNotFoundError) { |
| 472 | reply.send(errEnvelope(ErrorCode.PROMPT_NOT_FOUND, err.message, requestId)); |
| 473 | return; |
| 474 | } |
| 475 | if (err instanceof SessionNotFoundError) { |
| 476 | reply.send(errEnvelope(ErrorCode.SESSION_NOT_FOUND, err.message, requestId)); |
| 477 | return; |
| 478 | } |
| 479 | if (err instanceof FileNotFoundError) { |
| 480 | reply.send(errEnvelope(ErrorCode.FILE_NOT_FOUND, err.message, requestId)); |
| 481 | return; |
| 482 | } |
| 483 | if (err instanceof PromptImageFileTypeError) { |
| 484 | reply.send(errEnvelope(ErrorCode.VALIDATION_FAILED, err.message, requestId)); |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | if (err instanceof AuthProvisioningRequiredError) { |
| 489 | reply.send({ |
| 490 | code: ErrorCode.AUTH_PROVISIONING_REQUIRED, |
| 491 | msg: err.message, |
| 492 | data: null, |
| 493 | request_id: requestId, |
| 494 | details: null, |
| 495 | }); |
| 496 | return; |
| 497 | } |
| 498 | if (err instanceof AuthTokenMissingError) { |
| 499 | reply.send({ |
| 500 | code: ErrorCode.AUTH_TOKEN_MISSING, |
| 501 | msg: err.message, |
| 502 | data: null, |
| 503 | request_id: requestId, |
| 504 | details: { provider_id: err.providerId }, |
no test coverage detected