Catching Exceptions in Alintex Script

Some of the more eagle eyed amongst those who read my my previous post about writing a 'whois' script with Alintex Script .NET 1.1, pointed out that the code didn't handle exceptions.

Note:  see the Portable Script File Description at the bottom of the whois post to view the code.

The simple answer to that is that it does.  The Alintex Script application itself will ultimately catch any unhandled exception.  Infact, one can use that mechanism to easily report an error back to the user running the script.

For example, the following code will produce the output similar to that shown in the image below:-

[VB.NET]

#region "Script"
    throw new System.Exception("Where am I caught?")
#end region

[C#]

#region Script
    throw new System.Exception("Where am I caught?");
#endregion

[JScript.NET]

import System;
throw new System.Exception("Where am I caught?");

What about Java (J#)?

A script written in Java has the luxury of throwing a Java or .NET exception.  Alintex Script handles both.

[Java]

#region Script
    throw new java.lang.Exception("Where am I caught?");
#endregion

OR

#region Script
    throw new System.Exception("Where am I caught?");
#endregion

Of course you can choose to handle an exception in the script itself.

Additionally, there as an /unattended command line option that prevents the visible reporting of errors.

Another option lets you record all errors to the application event log as shown in the image below.

Please note that Alintex Script .NET 1.1 has not yet been released and is not available from the Alintex web site.

2 Comments

  • This shows one can throw exceptions, can one catch them instead of letting te script thingy giving a nasty pop-up?

  • Certainly one can handle an exception within the script itself. Additionally, there as a /unattended command line option that prevents the visible reporting of errors. An additional option lets you record all errors to the application event log.

Comments have been disabled for this content.