exceptionfactory commented on code in PR #6264:
URL: https://github.com/apache/nifi/pull/6264#discussion_r937022324


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java:
##########
@@ -1146,42 +1146,75 @@ public void addConnection(final Connection connection) {
             if (isInputPort(source)) { // if source is an input port, its 
destination must be in the same group unless it's an input port
                 if (isInputPort(destination)) { // if destination is input 
port, it must be in a child group.
                     if 
(!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection 
to Process Group because destination is an Input Port that does not belong to a 
child Process Group");
+                        throw new IllegalStateException("Cannot add Connection 
for Input Port[" + source.getIdentifier() +
+                                "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                                "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                                "] because destination [" + 
destination.getIdentifier() +
+                                "] is an Input Port that does not belong to a 
child Process Group");
                     }
                 } else if (sourceGroup != this || destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to 
Process Group because source and destination are not both in this Process 
Group");
+                    throw new IllegalStateException("Cannot add Connection for 
Input Port[" + source.getIdentifier() +
+                            "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                            "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                            "] destination [" + destination.getIdentifier() +
+                            "] because source and destination are not both in 
this Process Group");
                 }
             } else if (isOutputPort(source)) {
                 // if source is an output port, its group must be a child of 
this group, and its destination must be in this
                 // group (processor/output port) or a child group (input port)
                 if (!processGroups.containsKey(sourceGroup.getIdentifier())) {
-                    throw new IllegalStateException("Cannot add Connection to 
Process Group because source is an Output Port that does not belong to a child 
Process Group");
+                    throw new IllegalStateException("Cannot add Connection for 
Output Port[" + source.getIdentifier() +
+                            "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                            "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                            "] destination [" + destination.getIdentifier() +
+                            "] because source is an Output Port that does not 
belong to a child Process Group");
                 }
 
                 if (isInputPort(destination)) {
                     if 
(!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection 
to Process Group because its destination is an Input Port that does not belong 
to a child Process Group");
+                        throw new IllegalStateException("Cannot add Connection 
for Output Port[" + source.getIdentifier() +
+                                "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                                "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                                "] because destination [" + 
destination.getIdentifier() +
+                                "] is an Input Port that does not belong to a 
child Process Group");
                     }
                 } else if (destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to 
Process Group because its destination does not belong to this Process Group");
+                    throw new IllegalStateException("Cannot add Connection for 
Output Port[" + source.getIdentifier() +
+                            "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                            "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                            "] because its destination [" + 
destination.getIdentifier() +
+                            "] does not belong to this Process Group");
                 }
             } else { // source is not a port
                 if (sourceGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection to 
Process Group because the source does not belong to this Process Group");
+                    throw new IllegalStateException("Cannot add Connection 
from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                            "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                            "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                            "] because the source does not belong to this 
Process Group");
                 }
 
                 if (isOutputPort(destination)) {
                     if (destinationGroup != this) {
-                        throw new IllegalStateException("Cannot add Connection 
to Process Group because its destination is an Output Port but does not belong 
to this Process Group");
+                        throw new IllegalStateException("Cannot add Connection 
from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                                "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                                "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                                "] because its destination [" + 
destination.getIdentifier() +
+                                "] is an Output Port that does not belong to 
this Process Group");
                     }
                 } else if (isInputPort(destination)) {
                     if 
(!processGroups.containsKey(destinationGroup.getIdentifier())) {
-                        throw new IllegalStateException("Cannot add Connection 
to Process Group because its destination is an Input "
-                            + "Port but the Input Port does not belong to a 
child Process Group");
+                        throw new IllegalStateException("Cannot add Connection 
from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                                "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                                "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                                "] because its destination [" + 
destination.getIdentifier() +
+                                "] is an Input Port but the Input Port does 
not belong to a child Process Group");
                     }
                 } else if (destinationGroup != this) {
-                    throw new IllegalStateException("Cannot add Connection 
between " + source.getIdentifier() + " and " + destination.getIdentifier()
-                        + " because they are in different Process Groups and 
neither is an Input Port or Output Port");
+                    throw new IllegalStateException("Cannot add Connection 
from " + source.getConnectableType().name() + "[" + source.getIdentifier() +
+                            "] from Process Group [" + 
sourceGroup.getIdentifier() +
+                            "] to Process Group [" + 
destinationGroup.getIdentifier() +
+                            "] destination " + 
destination.getConnectableType().name() + "[" + destination.getIdentifier() +

Review Comment:
   Is there a reason for including the Connectable Type name value in this 
message but not the others?
   
   In light of the similarities, what do you think about creating a simple 
method for formatting the source and destination messages to ensure consistency?



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