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

Function sendMappedError

packages/server/src/routes/files.ts:240–286  ·  view source on GitHub ↗
(reply: FilesReply, requestId: string, err: unknown)

Source from the content-addressed store, hash-verified

238}
239
240function sendMappedError(reply: FilesReply, requestId: string, err: unknown): void {
241 if (err instanceof FileNotFoundError) {
242 reply
243 .code(404)
244 .send(errEnvelope(ErrorCode.FILE_NOT_FOUND, 'file not found', requestId));
245 return;
246 }
247 if (err instanceof FileTooLargeError) {
248 reply
249 .code(413)
250 .send(
251 errEnvelope(
252 ErrorCode.FILE_TOO_LARGE,
253 'upload too large (>50MB)',
254 requestId,
255 ),
256 );
257 return;
258 }
259
260 if (
261 typeof err === 'object' &&
262 err !== null &&
263 'name' in err &&
264 (err as { name: string }).name === 'FST_REQ_FILE_TOO_LARGE'
265 ) {
266 reply
267 .code(413)
268 .send(
269 errEnvelope(
270 ErrorCode.FILE_TOO_LARGE,
271 'upload too large (>50MB)',
272 requestId,
273 ),
274 );
275 return;
276 }
277 reply
278 .code(500)
279 .send(
280 errEnvelope(
281 ErrorCode.INTERNAL_ERROR,
282 err instanceof Error ? err.message : 'internal error',
283 requestId,
284 ),
285 );
286}
287
288const fieldValueSchema = z.object({ value: z.unknown() });
289

Callers 1

registerFilesRoutesFunction · 0.70

Calls 3

errEnvelopeFunction · 0.90
sendMethod · 0.65
codeMethod · 0.65

Tested by

no test coverage detected