(reply: FilesReply, requestId: string, err: unknown)
| 238 | } |
| 239 | |
| 240 | function 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 | |
| 288 | const fieldValueSchema = z.object({ value: z.unknown() }); |
| 289 |
no test coverage detected