Skip to main content

Suppressing error messages

Hi Brian,
I am implementing CaseWare Monitor and that will be used to run my scripts and manage the subsequent exceptions. To do this, I can't have any message boxes pop up through the script, including error messages, as CaseWare Monitor will just hang waiting for the user to press OK.
The problem is, I have a lot of standard functions as separate scripts (my script library) and I call those using Client.RunIDEAScriptEx. If there is a problem with calling that script, IDEA automatically throws up a message to say there was an error in calling the script. I have error handling routines in both the main and library scripts, but I can't find a way to suppress the initial error message.
Do you know of a way to suppress all error messages? Unfortunately if I can't find a way around this I will just have to convert all of those library scripts back to functions in my main script. :(
Regards
Laura

Brian Element Thu, 05/07/2015 - 08:26

Hi Laura,

I will have to test this out as I am not sure off hand.  Will you be writing your error messages to a log file instead of using the pop-up boxes?

I will try and have a look at this tonight as I am away this weekend, if not I will get back to you next week if I can find a solution for you.

Thanks

Brian

laura.garner Thu, 05/07/2015 - 18:38

Thanks Brian. I am still working out the best way to log an error so I know what has happened. I wanted to send an email so I would be informed straight away but I don't have an email program on the server that CaseWare Monitor and IDEA are sitting on.
Thanks again
Laura

laura.garner Sun, 05/10/2015 - 01:39

Just a quick update - the invasive error message doesn't just happen when calling an external script. It is actually for any error that IDEA pops up a message. I now have an error handler which writes to a log file, but I still can't get around having to press OK on the initial message. I even tried putting in a wait call and using SendKeys to press enter, but by that time the script has already paused waiting for the OK. I'm really hoping that I have missed something obvious...

Brian Element Sun, 05/10/2015 - 07:56

Hi Laura,

Did you try something like this, In this example the script does Not exist but there is no popup, it just writes a Log file.

Const ForReading = 1
Const ForWriting = 2

Sub Main
	Dim fso As Object
	Dim f As Object
	On Error GoTo ErrorHandler
	Client.RunIDEAScript "This Script Does not exist.ISS"
	Exit Sub
ErrorHandler:
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.OpenTextFile("c:\data\testfile.txt", ForWriting, True)
	f.WriteLine "There was an error!"
	Set fso = Nothing
	Set f = Nothing

End Sub

 

laura.garner Mon, 05/11/2015 - 17:43

 
Hi Brian,
I tried your script as it sits and it worked exactly as I need it to - no pop ups! But when I moved your error handler into my script I get the pop ups again. I re-created the script with a single import command, and I have attached it for your reference. Please note, I have pretty much taught myself scripting with absolutely no training, so please be kind with any criticism!
 
I force an error by not having the correct record definition file, and it pops up with an error saying it is an invalid macro filename. Once I click ok then it goes to the error handler and writes to the log file.
 
Can you see what I am doing wrong?!
 
 Regards
Laura

Brian Element Mon, 05/11/2015 - 19:12

Hi Laura,

You have to put the On Error Goto ErrHandler and the ErrHandler: in each function.  So you have the sub main covered but you need to add it also in your TextImport function.  Right now if you get an error in the TextImport you will get a pop-up.

Script looks fine, the only thing I might change and this is a personal preference is I would use a select case statement instead of the multi layer else statement.

Thanks

Brian

laura.garner Mon, 05/11/2015 - 19:26

Brian, you are the absolute best!! That worked exactly as I need it to. Now I just need to go and add the error handling into each function.
I will also look at the select case statement.
Thank you so much!!!
Laura