You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/07/15 06:53:43 UTC

[GitHub] [netbeans] tmysik commented on a change in pull request #2250: Minor improvements for php.api.phpmodule

tmysik commented on a change in pull request #2250:
URL: https://github.com/apache/netbeans/pull/2250#discussion_r454831171



##########
File path: php/php.api.phpmodule/src/org/netbeans/modules/php/api/validation/ValidationResult.java
##########
@@ -80,6 +81,20 @@ public boolean hasErrors() {
         return new ArrayList<>(errors);
     }
 
+    /**
+     * Get the first error.
+     *
+     * @return the first error.
+     * @since 2.72
+     */
+    @CheckForNull
+    public Message getFirstError() {
+        if (hasErrors()) {
+            return errors.get(0);
+        }
+        return null;
+    }

Review comment:
       I think that `Message.EMPTY` would complicate things because the caller would need to (a) check whether it is an empty message (which is similar for the current check for `null`) or (b) adjust UI not to show the empty error as an error.
   
   Using `Optional` would be better but I would perhaps keep the current implementation, it is more _consistent_ with the rest of the NetBeans codebase (and we have `@CheckForNull`). But up to you, feel free to use it if you want to, I definitely have no objections.
   
   Thanks.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists