Sometimes a script will fail with no apparent cause. The usual course of action is to check the log window, but sometimes there is just silence – an empty trail with no leads to follow. But there is a another source of information, the global variable exception_msg.
This is the scenario I am dealing with at the moment. I have a table open. When it closes some actions need to be performed. I perform those actions by associating a script to the On Close event. But the script fails. Silently. By inserting some show messages I track down the problem to a line of code:
1 |
source = Current Data Source(); |
Where Current Data Source is a function that I have defined. The function is in scope because I have an include statement as part of the on close event handler.
To utilise the exception message I can bracket the statement within a Try block:
1 2 3 4 5 |
Try( source = Current Data Source() , show( exception_msg ) ); |
Here is the message I get in the log window:
1 2 |
exception_msg = {"Name Unresolved: Get Project Path Namespace"(1, 2, "Get Project Path Namespace", Get Project Path Namespace() /*###*/)}; |
My user-defined function accesses data within a namespace. The reference to the namespace is obtained by calling another user-defined function Get Project Path Namespace. This function is out of scope; I need an additional include statement within the event handler – problem solved.