* Map a thrown error to the right envelope. See module header for the table.
(
reply: { send(payload: unknown): unknown },
requestId: string,
err: unknown,
)
| 165 | * Map a thrown error to the right envelope. See module header for the table. |
| 166 | */ |
| 167 | function sendMappedError( |
| 168 | reply: { send(payload: unknown): unknown }, |
| 169 | requestId: string, |
| 170 | err: unknown, |
| 171 | ): void { |
| 172 | if (err instanceof SessionNotFoundError) { |
| 173 | reply.send(errEnvelope(ErrorCode.SESSION_NOT_FOUND, err.message, requestId)); |
| 174 | return; |
| 175 | } |
| 176 | if (err instanceof SkillNotFoundError) { |
| 177 | reply.send(errEnvelope(ErrorCode.SKILL_NOT_FOUND, err.message, requestId)); |
| 178 | return; |
| 179 | } |
| 180 | if (err instanceof SkillNotActivatableError) { |
| 181 | reply.send(errEnvelope(ErrorCode.SKILL_NOT_ACTIVATABLE, err.message, requestId)); |
| 182 | return; |
| 183 | } |
| 184 | throw err; |
| 185 | } |
no test coverage detected