From 3df51cf4b138daf225f6b8daeb69662c7219f407 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 6 Jun 2025 01:06:07 -0400 Subject: [PATCH] Refactor error handling in attachment operations: standardize error messages and remove logging statements --- src/FederationServer/Methods/Attachments/DeleteAttachment.php | 1 - .../Methods/Attachments/DownloadAttachment.php | 2 +- src/FederationServer/Methods/Attachments/UploadAttachment.php | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/FederationServer/Methods/Attachments/DeleteAttachment.php b/src/FederationServer/Methods/Attachments/DeleteAttachment.php index ec31262..c36335a 100644 --- a/src/FederationServer/Methods/Attachments/DeleteAttachment.php +++ b/src/FederationServer/Methods/Attachments/DeleteAttachment.php @@ -62,7 +62,6 @@ } catch(DatabaseOperationException $e) { - Logger::log()->error(sprintf('Failed to delete attachment %s: %s', $attachmentUuid, $e->getMessage()), $e); throw new RequestException('Internal Server Error: Unable to create operator', 500, $e); } diff --git a/src/FederationServer/Methods/Attachments/DownloadAttachment.php b/src/FederationServer/Methods/Attachments/DownloadAttachment.php index 278f5f3..447057b 100644 --- a/src/FederationServer/Methods/Attachments/DownloadAttachment.php +++ b/src/FederationServer/Methods/Attachments/DownloadAttachment.php @@ -65,7 +65,7 @@ } catch(Throwable $e) { - throw new RequestException('Error retrieving attachment: ' . $e->getMessage(), 500, $e); + throw new RequestException('Internal server error while retrieving attachment', 500, $e); } $fileLocation = Configuration::getServerConfiguration()->getStoragePath() . DIRECTORY_SEPARATOR . $attachment->getUuid(); diff --git a/src/FederationServer/Methods/Attachments/UploadAttachment.php b/src/FederationServer/Methods/Attachments/UploadAttachment.php index b4c42cb..cdbb33a 100644 --- a/src/FederationServer/Methods/Attachments/UploadAttachment.php +++ b/src/FederationServer/Methods/Attachments/UploadAttachment.php @@ -4,7 +4,6 @@ use FederationServer\Classes\Configuration; use FederationServer\Classes\Enums\AuditLogType; - use FederationServer\Classes\Logger; use FederationServer\Classes\Managers\AuditLogManager; use FederationServer\Classes\Managers\EvidenceManager; use FederationServer\Classes\Managers\FileAttachmentManager; @@ -153,14 +152,12 @@ { // If database insertion fails, remove the file to maintain consistency @unlink($destinationPath); - Logger::log()->error(sprintf('Failed to record file upload for evidence %s: %s', $evidenceUuid, $e->getMessage()), $e); throw new RequestException('Internal Server Error: Unable to create file attachment record', 500, $e); } catch (Throwable $e) { // Handle any other unexpected errors @unlink($destinationPath); - Logger::log()->error(sprintf('Unexpected error during file upload for evidence %s: %s', $evidenceUuid, $e->getMessage())); throw new RequestException('Internal Server Error', 500, $e); } finally