MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / sendMappedError

Function sendMappedError

packages/server/src/routes/skills.ts:167–185  ·  view source on GitHub ↗

* Map a thrown error to the right envelope. See module header for the table.

(
  reply: { send(payload: unknown): unknown },
  requestId: string,
  err: unknown,
)

Source from the content-addressed store, hash-verified

165 * Map a thrown error to the right envelope. See module header for the table.
166 */
167function 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}

Callers 1

registerSkillsRoutesFunction · 0.70

Calls 2

errEnvelopeFunction · 0.90
sendMethod · 0.65

Tested by

no test coverage detected