From aebd51788b423e40072e628bc2e84444196d20a6 Mon Sep 17 00:00:00 2001 From: BillionClaw <267901332+BillionClaw@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:05:52 +0800 Subject: [PATCH] fix: improve error messages for file/folder already exists --- .../repositories/pg/file_blob_write_repository.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/infrastructure/repositories/pg/file_blob_write_repository.rs b/src/infrastructure/repositories/pg/file_blob_write_repository.rs index 45b9d552..1562ea34 100755 --- a/src/infrastructure/repositories/pg/file_blob_write_repository.rs +++ b/src/infrastructure/repositories/pg/file_blob_write_repository.rs @@ -257,7 +257,7 @@ impl FileWritePort for FileBlobWriteRepository { { return Err(DomainError::already_exists( "File", - format!("{name} already exists in folder"), + format!("'{name}' already exists in this folder"), )); } return Err(DomainError::internal_error( @@ -382,7 +382,7 @@ impl FileWritePort for FileBlobWriteRepository { { return DomainError::already_exists( "File", - "File with that name already exists in target folder".to_string(), + "a file with this name already exists in the target folder", ); } DomainError::internal_error("FileBlobWrite", format!("copy: {e}")) @@ -440,7 +440,7 @@ impl FileWritePort for FileBlobWriteRepository { if let sqlx::Error::Database(ref db_err) = e && db_err.code().as_deref() == Some("23505") { - return DomainError::already_exists("File", format!("{new_name} already exists")); + return DomainError::already_exists("File", format!("'{new_name}' already exists")); } DomainError::internal_error("FileBlobWrite", format!("rename: {e}")) })? @@ -632,7 +632,7 @@ impl FileWritePort for FileBlobWriteRepository { if db_err.code().as_deref() == Some("23505") { return DomainError::already_exists( "Folder", - "A folder with that name already exists in the target".to_string(), + "a folder with this name already exists in the target location", ); } }