I previously had difficulty manually inserting error handling
code. This time, I decided to create my own global error
handler by creating a simple program that opens my source
code and automatically inserting On Error Goto ... at the
beginning of each routine, with error handling code at the end
of the routine. It seemed like a solution that would finally
save time in debugging. But this time I got Error #51. The help
file says to contact Tech Support when this error happens.
I started trying to narrow down exact cause of error 51 but I
stopped, because unlike other GPFs that you can just click out
of, this time I was getting hard crashes that froze the whole
computer, and even <ctrl><alt><del> wouldn't respond to.
I was not able to duplicate Error 51 in a short piece of postable
code, but I think I have a general idea what may have triggered
it. It turns out that there was an array that was incorrectly
accessed. However, "On Error GoTo" simply didn't catch it, and
the intricate program just kept on going, until it couldn't any
more and displayed Error 51. Although I don't have concise code
to demonstrate Error 51 I here is something that shows where
"On Error GoTo" fails.
Notice that I am accessing MyArray(-1) -- when the array goes
from 0 to 100. On Error doesn't catch it. In the
actual project, it kept on going until a different location
where that array was redimmed, and then it gave error 51.
Something interesting that I noticed was that "On Error" didn't
seem to work in a DLL, or when I ran it as a regular EXE. However,
when I ran it from the debugger, it worked kind of the way I had
in mind for it to.
But even the debugger didn't trap a GoTo DWORD null correctly.
Thankfully it softly said General Protection Fault in the
debugger and let me gracefully click out of that one. But I
think it should return error #9 for that one as well.
------------------
Daniel Corbier
UCalc Fast Math Parser
http://www.ucalc.com
code. This time, I decided to create my own global error
handler by creating a simple program that opens my source
code and automatically inserting On Error Goto ... at the
beginning of each routine, with error handling code at the end
of the routine. It seemed like a solution that would finally
save time in debugging. But this time I got Error #51. The help
file says to contact Tech Support when this error happens.
I started trying to narrow down exact cause of error 51 but I
stopped, because unlike other GPFs that you can just click out
of, this time I was getting hard crashes that froze the whole
computer, and even <ctrl><alt><del> wouldn't respond to.
I was not able to duplicate Error 51 in a short piece of postable
code, but I think I have a general idea what may have triggered
it. It turns out that there was an array that was incorrectly
accessed. However, "On Error GoTo" simply didn't catch it, and
the intricate program just kept on going, until it couldn't any
more and displayed Error 51. Although I don't have concise code
to demonstrate Error 51 I here is something that shows where
"On Error GoTo" fails.
Code:
' ------ Beginning of Program $Compile Exe Function DoSomething(x As Long, y As Long) As String On Error GoTo ErrorHandler Dim MyArray(x) As Long MyArray(y) = MyArray(y-1) ' Should catch MyArray(-1) DoSomething = "There were no errors" Exit Function ErrorHandler: DoSomething = "Error #"+Str$(Err)+" in Function: Other" End Function Function PbMain As Long MsgBox DoSomething(100, 0) End Function ' ------ End of Program
from 0 to 100. On Error doesn't catch it. In the
actual project, it kept on going until a different location
where that array was redimmed, and then it gave error 51.
Something interesting that I noticed was that "On Error" didn't
seem to work in a DLL, or when I ran it as a regular EXE. However,
when I ran it from the debugger, it worked kind of the way I had
in mind for it to.
But even the debugger didn't trap a GoTo DWORD null correctly.
Thankfully it softly said General Protection Fault in the
debugger and let me gracefully click out of that one. But I
think it should return error #9 for that one as well.
------------------
Daniel Corbier
UCalc Fast Math Parser
http://www.ucalc.com
Comment