I have an instance where a Try:Catch is throwing an exception in my visionWindowOpened. In this case, I want to display a MessageBox for the operator and then close out the Window once they acknowledge the error.
The message box piece works, but I cannot seem to close the window. I get a Java error when I try to close the window. I assume this is because the Window has not completed the Open at this point. Is there a way around this?
Example:
system.gui.messageBox(“Please verify system is online.”,“System Unavailable.”)
system.nav.closeWindow("{Window Name}")
try:
if system.gui.getParentWindow(event).getComponentForPath('Root Container.tblLocationCodes').data == None
system.gui.getParentWindow(event).getComponentForPath('Root Container').errorWindowsClose = False
except:
system.gui.messageBox("Please verify system is online","System Unavailable.")
system.nav.closeWindow("addLocationCode")
I am reaching the MessageBox as expected, but am getting a Java NullPointer error on the closeWindow. I pulled out all of the code except for the closeWindow command and got the same error.
Error on Close:
Traceback (most recent call last):
File “event:actionPerformed”, line 11, in
java.lang.NullPointerException: java.lang.NullPointerException
caused by NullPointerException
Ignition v8.1.7 (b2021060314)
Java: Azul Systems, Inc. 11.0.11
I was able to get around this by setting a custom property and then checking for that property to change in the Root Container Script. It works, but seems like a lot of extra code.