Hi,
Sometimes i get very strange error in following code:
Public Const LibName = "(folder Today) "
Sub Click(Source As Button)
On Error Goto Except
Common_ViewAction_MarkSelf_UI 'error in this line!
Goto Finally
Except:
CommonTools_CommonErrorHandler LibName + "action MarkSelf", Err, Erl, Error$, Nothing
Resume Finally
Finally:
End Sub
Seems that error is in Common_ViewAction_MarkSelf_UI sub, but it’s definitely not:
Private Const LibName = "(Time2_Internal_UI) "
Public Sub Common_ViewAction_MarkSelf_UI
On Error GoTo Except
some code here
...
...
GoTo Finally
Except:
Error Err, LibName + "Common_ViewAction_MarkSelf_UI line " + CStr(Erl) + Chr$(10) + Error$
Finally:
End Sub
If error occurring in Common_ViewAction_MarkSelf_UI, then error string will contain that sub name. But error string is the following:
(folder Today) action MarkSelf line 4
Expression out of range
What can be wrong with the sub call in line 4 in Click sub?
Subject: RE: Strange LS error
Another suggestion is to beef up your error message. Here’s what I put in mine:
Msgbox "Error: " & Error & " at " & cstr(erl) & " of " & getThreadInfo(1) & " in " & session.currentAgent.name
(If it’s not an agent you can leave off the last part of course.) Anyway, that’ll tell you the error, the line number and the subroutine/function that the error occurred in.
Subject: Turn off error handling…
Then run the code in the debugger and see what really happens.
I would also suggest a few little tweaks to your code to make it easier to read as well as simpler.
Sub Click(Source As Button)
On Error Goto Except
Common_ViewAction_MarkSelf_UI
Goto Finally
Except:
CommonTools_CommonErrorHandler LibName + “action MarkSelf”, Err, Erl, Error$, Nothing
Resume Finally
Finally:
End Sub
I would rewrite it like this:
Sub Click(Source As Button)
On Error Goto errHandler
Call Common_ViewAction_MarkSelf_UI()
exitSub:
Exit Sub
errHandler:
Call CommonTools_CommonErrorHandler(LibName + “action MarkSelf”, Err, Erl, Error$, Nothing)
Resume exitSub
End Sub
Much easier to read, and you make it clear what are function/subroutien calls. You also avoid extra goto jumps.