Copilot commented on code in PR #11443:
URL: https://github.com/apache/cloudstack/pull/11443#discussion_r2276872903


##########
api/src/main/java/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java:
##########
@@ -97,17 +96,12 @@ public long getEntityOwnerId() {
 
     @Override
     public void execute() {
-        if (ids == null && type == null && endDate == null) {
-            throw new InvalidParameterValueException("either ids, type or 
enddate must be specified");
-        } else if (startDate != null && endDate == null) {
-            throw new InvalidParameterValueException("enddate must be 
specified with startdate parameter");
-        }
         boolean result = _mgr.deleteEvents(this);
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());
             setResponseObject(response);
         } else {
-            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable 
to delete Events, one or more parameters has invalid values");
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable 
to delete any events. One or more parameters have invalid values.");

Review Comment:
   The error message suggests parameter validation issues, but the method now 
returns false when no events are deleted (totalRemoved = 0), which could happen 
even with valid parameters if no matching events exist. Consider a more 
accurate message like "No events found matching the specified criteria" or 
differentiate between validation errors and no matching records.
   ```suggestion
               throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, 
"Unable to delete any events. No events found matching the specified criteria 
or one or more parameters have invalid values.");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to