Skip to main content
Version: 8.1

Reading Error Messages

When an error occurs in the execution of a script, an error message box will pop up. The popup box appears in front of any open Designer windows, and will remain in view until you close it or click on something behind it.

There are two modes for the Error box selectable by the Send to Front and Send to Back icons.

  • Send to Front means additional error messages will cause the popup to reappear on top.
  • Send to Back will cause the errors to remain hidden below the Designer.

Error Message Box Overview

Exceptions usually include a line number. Take note of the number in the Details tab, and start your search for the problem there. Be aware, however, that the line reported may not be the cause of the issue. The actual problem may be higher up in the code due to a faulty initialization, or some other issue. When troubleshooting, always start looking at the line reported, and work your way back towards the top.

When testing a script, you may come across an Error Message Box like the following. Your first inclination may be to close the error without closer examination: resist it!

The error messages generated from failed script executions are incredibly helpful. The Message tab on the error describes the Event Handler that encountered the exception; in this case, the actionPerformed event handler. This is important in cases where multiple Event Handlers on the same component have scripts. Without knowing which Event Handler generated the script, we could waste time trying to troubleshoot the wrong script.

Additionally, it shows the name of the component, which is "NavButton_MyWindow". Again, this is helpful if multiple scripts from multiple components are triggering in quick succession. The Message tab will clearly point you towards the source of the exception. This is another reason to give meaningful names to your components: doing so makes the process of tracking an error much easier.

The Details tab has even more information, specifically the line number that the exception occurred on, as well as the error message. The message here states that the window at path "MyWindow" does not exist, so we can check the Project Browser to see if we simply mistyped the name of the window.

Troubleshooting Errors Using the Error Message Box

When we don't get our expected results from our script, as in the following examples, always read both the Message and Details tabs in the Error Message Box. They are pretty good about pointing you to the root cause of your error. From there, you can easily find and fix any errors in your script.

The following examples show how to troubleshoot some of these error messages from the Error Message Box. Keep in mind that every script is unique, but at least you'll become familiar with what some of the error messages mean, and gain a little insight of the troubleshooting process.

Broken Example - Incorrect Attribute

In the following script, when a Button is pressed a Message Box is supposed to open on a window and display "Hello World".

Python - Broken: Incorrect Attribute
system.gui.messagebox("Hello World")

From the error message box, you know two important things right away:

  • The script is using the actionPerformed event on the Hello Button.
  • Line 1 displays the description of the error.

Check to be sure you used the correct attribute. Then check the spelling, case sensitive letters, spacing, and operators in your script. If you are familiar with Ignition's Built-in Scripting Functions, you can probably spot the error immediately. If not, you might want to use the autocompletion popup feature to retype your 'messageBox' scripting function. This will automatically fix any syntax errors.

The error in this example is in the attribute name. It uses case sensitive letters (i.e., messageBox).

In this case, "messagebox" must be spelled with a capital "B" since we're trying to use Ignition's system.gui.messageBox function. We corrected the script by changing our code to the following:

Python - Corrected: Incorrect Attribute
system.gui.messageBox("Hello World")

Broken Example - Undefined

Here is a similar script. When a Button is pressed, it's supposed to open a Message Box on a window and display "Testing".

Python - Broken: Undefined

The Error Message Box displays an error on the actionPerformed script on the button component in line 1 with an undefined name. The Details tab is simply telling us that something is not defined in the script. You can either define a variable or create a string by putting "Testing" in quotes to correct the error.

For this example, we corrected the code by turning the argument passed to system.gui.messageBox into a string literal with quotation marks:

Python - Corrected: Undefined

Broken Example - Type Error

Similar to the other scripts, this script opens a Message Box and is supposed to display "100" when a Button is pressed.

Python - Broken: TypeError

Since this script failed to execute successfully, the Error Message Box popped up and displayed an error on the actionPerformed script on the button component in line 1 with a TypeError. This error tells us that the first parameter is expecting a string, not an integer.

For this example, we corrected the code by changing the argument passed to system.gui.messageBox into a string literal with quotation marks.

Python - Corrected: TypeError

You can see from the examples above, that the Error Message Box provides quite a bit of information that points to the root cause of an error on an Event Handler script. As you learn from the Error Message Boxes about what these messages mean, you'll be able to quickly spot them in your script and quickly correct any errors you encounter.