* Handles body size limit errors by logging and throwing a user-friendly error * @param error - The original error * @param requestId - Request ID for logging * @param context - Context string for logging (e.g., toolId) * @throws Error with user-friendly message if it's a size limit error * @re
(error: unknown, requestId: string, context: string)
| 742 | * @returns false if not a size limit error (caller should continue handling) |
| 743 | */ |
| 744 | function handleBodySizeLimitError(error: unknown, requestId: string, context: string): boolean { |
| 745 | const errorMessage = toError(error).message |
| 746 | |
| 747 | if (isBodySizeLimitError(errorMessage)) { |
| 748 | logger.error(`[${requestId}] Request body size limit exceeded for ${context}:`, { |
| 749 | originalError: errorMessage, |
| 750 | }) |
| 751 | throw new Error(BODY_SIZE_LIMIT_ERROR_MESSAGE) |
| 752 | } |
| 753 | |
| 754 | return false |
| 755 | } |
| 756 | |
| 757 | function handleResponseSizeLimitError(error: unknown, requestId: string, context: string): boolean { |
| 758 | if (!isPayloadSizeLimitError(error)) return false |
no test coverage detected