I'm doing some changes to the Quality Center workflow editor. My code isn't working, but instead of getting an error message from QC, I get nothing.
I've added On Error GoTo 0 in the beginning of my function, but that also doesn't help.
I have removed my On Error GoTo 0 from the method which is failing, but a higher level method which calls the failing method still has On Error GoTo 0. I don't want to change this higher method as I didn't create it. Is there a way to set the error handling back to default?
I found "On Error GoTo -1", but Quality Center doesn't allow me to save this:
The script successfully passed syntax check.
[Error] (L715: c17): Syntax error
If 'On Error GoTo 0' should never be at the TOP of a function (or sub).
If you look the pattern in the subs and functions that QC/ALM come with out of the box you'll notice that the first thing that often appears after the definition is
On Error Resume Next
This translates to something like "if something goes wrong, carry on!"
On Error GoTo 0 is an instruction to reset the error object if any errors have been raised. To trap and notify of errors a good idea is to write a function to perform this task, and call it at the bottom of your sub immediately before 'On Error GoTo 0'
On Error Resume Next
' code in here where something could go wrong
On Error GoTo 0
At the end of someFunction, we will call 'CheckForErrors()' and we will tell it what function we're calling it from. CheckForErrors will let us know if any errors were raised.
Since we know that following this call the error will have been handled, we can safely reset the err object with On Error Goto 0 back in our original function.
Now we need to add our CheckForErrors() function. Something like this may help:
If Err.Number <> 0 Then
msgbox "Error raised by " & cstr(callingFunction) & " vbcrlf & "Error number: " & Err.Num & vbcrlf & "Source: " & Err.Source & vbcrlf & Error Description: " & err.Description
It's worth pointing out that CheckForErrors() is going to be executed whether there's an error or not, but it's only going to pop up a message box if an error does exist.