Odd RuntimeException error

I have some code in a MenuItem.Enable event, a customer recently reported that it raised a RuntimeException error (as reported by my OopsMsg method).

Without watching it execute, I can’t tell exactly what the problem is, but the code hasn’t been touched in years and is really trivial. Does anyone have thoughts on what might be causing the exception?

Here is the code (Me is the FontMenuItem that this code is part of):

// MyWnd is a window property of the MenuItemClass
// MyWnd.LayHere is a property of the MyWnd class
// MyWnd.LayoutPJO is a property of the MyWnd class

If MyWnd=Nil Then Return

if MyWnd.WorkMode<>kLayingOut Then Return
if MyWnd.LayHere=Nil Then Return
if MyWnd.LayoutPJO=Nil then Return

If Me.Tag<>Nil and Me.Tag="FontPrefs" Then
  Me.Enabled=True
  Return
End If

Return

Exception Err as RuntimeException
  If Err IsA EndException Or Err IsA ThreadEndException Then
    Raise err //Re-raise the exception
  End If
  OopsMsg CurrentMethodName, Err, Erln
  Return

First, Use introspection to see what kind of exception it is.

I’ll give introspection a try, this is the first time this bug has surfaced, whatever is is. Hopefully next time will be easier to puzzle out - or even better, never happen again…:8ball: Thanks!

Look in the docs for runtimeException. There should be an example that’s something like this:

Dim name as String = Introspection.GetType(err).Name

And then just output the name and description in your error code

Actually, I’d forgotten that My OopsMsg method does that:

ErrorTypeStr=Introspection.GetType(ErrE).FullName
ErrMsgStr = ErrorTypeStr+" error in "+MethodStr

in this case it returns just: “RuntimeException error in FontMenuItem.EnableMenu”, plus the release version of the app.

However, without line numbers I can’t see which of those 9 lines of code was the culprit - or if it was something outside of my code. There are pictures attached to that menu, perhaps there was something wrong with them (they’re generated on the fly as font samples).

Is there any chance that the Tag is an object here? You’d probably get a typemismatch for that when comparing to a string.