I am using REALBasic 2009 Release 1 on Mac OS X 10.5.6.
I have been searching through these forums, checking the Language Reference, and included example files but I cannot figure out how to handle an error that I am getting.
I am writing a Console Application for Windows that I am passing one or two file pathnames as arguments on the command line. I check the number and contents of the args() being read in with a boolean function. This function works properly and then I use the following code to read FolderItem of args(1).
Code snippit in the Run Event Handler.
if not CheckArguments( args ) then return -1
sourcef = GetFolderItem(args(1))
if sourcef <> nil then
' Process files here
mess = args(1) + " is not a valid SDF file"
Exception err as NilObjectException
StdErr.WriteLine("Invalid file. Bye!")
Code in the UnhandledException Event Handler
if error IsA NilObjectException then
StdErr.WriteLine("Very Bad file")
When a valid file path is passed, the code runs fine and the program executes without any errors.
When a partial or invalid file path is passed,the console outputs the following:
Exception Error Number: 0
An exception of class NilObjectException was not handled. The application must
And Windows also throws up the Program crash dialog box for reporting the error to Microsoft
So it looks like the UnhandledExeception code is being run, and not the Exception block at the end of the Run event. Also the else statements are not executed as I would have expected a different message.
How am I supposed to handle the exception if the methods above are not catching the error? Am I missing something? I have also tried to use Try...Catch...End Try blocks as well with the same result.