diff --git a/my-postgres-core/src/connection_sql_operations.rs b/my-postgres-core/src/connection_sql_operations.rs index beccdd9..487ce53 100644 --- a/my-postgres-core/src/connection_sql_operations.rs +++ b/my-postgres-core/src/connection_sql_operations.rs @@ -349,7 +349,7 @@ impl PostgresConnection { let key = entity.get_primary_key_as_single_string(); if has_entities.contains(&key) { - panic!("Duplicated entity in bulk_insert_or_update_db_entity for table: {}. PrimaryKey: {}", table_name, key); + return Err(MyPostgresError::Other(format!("Duplicated entity in bulk_insert_or_update_db_entity for table: {}. PrimaryKey: {}", table_name, key))); } has_entities.insert(key); diff --git a/my-postgres-core/src/my_postgres.rs b/my-postgres-core/src/my_postgres.rs index 0af2c9e..5b9bfda 100644 --- a/my-postgres-core/src/my_postgres.rs +++ b/my-postgres-core/src/my_postgres.rs @@ -358,7 +358,9 @@ impl MyPostgres { #[cfg(feature = "with-logs-and-telemetry")] telemetry_context: Option<&MyTelemetryContext>, ) -> Result<(), MyPostgresError> { if entities.len() == 0 { - panic!("Attempt to bulk_insert_or_update_db_entity 0 entities"); + return Err(MyPostgresError::Other( + "Attempt to bulk_insert_or_update_db_entity 0 entities".to_string(), + )); } self.connection