Try/catch failing for InvalidArgumentException

Got an error report from a user regarding an InvalidArgumentException

[quote]2019-02-04, 2:25:38 PM Class/Method: MimeImagePreview.MakeImagePreview
2019-02-04, 2:25:38 PM Time: Monday, February 4, 2019 2:25:38 PM 3565554
2019-02-04, 2:25:38 PM Type of Error: InvalidArgumentException[/quote]

To check what the problem is I wrapped the code with a try/catch:

try dim image as new GMImageMBS(PreviewPic) image.autoOrient PreviewPic = image.CopyPicture(0, 0, image.columns, image.rows) catch err as InvalidArgumentException Globals.theAppLog.AddToAppLog("InvalidArgumentException for " + App.MailFields.MainSubject, "") end try

But why does Xojo tell me: “Can’t find a type with this name. Did you mean Xojo.Core.InvalidArgumentException?” Xojo 2018r3, High Sierra.

Possibly because it is in the new framework but not the old one?

Have you tried

Catch err as Xojo,Core.InvalidArgumentException

Have you tried if Application.UnhandledException catches it?

The docs says it’s an InvalidArgumentException and not a Xojo.Core one: http://docs.xojo.com/InvalidArgumentException

I also don’t think that Christian’s code does a Xojo.core exceptions anywhere.

I get the type with Introspection, which should give me the correct type

dim ErrorInfo as Introspection.TypeInfo = Introspection.GetType(theError) dim theResult as String = ErrorInfo.Name

App.UnhandledException is a no-go because I have a dedicated error handling routine. UnhandledException doesn’t work in a thread anyways.

And a bare

try catch err as InvalidArgumentException end try
also doesn’t work and gives the same error.

[quote=424053:@Beatrix Willius]The docs says it’s an InvalidArgumentException and not a Xojo.Core one: http://docs.xojo.com/InvalidArgumentException

I also don’t think that Christian’s code does a Xojo.core exceptions anywhere.[/quote]

Right, and as we all know there are no errors in the documentation, and Xojo works exactly as the documentation says.

Even though the compiler says that’s where the problem is?

Wouldn’t it be easier to just try

Catch err as Xojo,Core.InvalidArgumentException

rather than explain why that shouldn’t work?

The Xojo.Core exception won’t work because it’s not the correct type. It’s a bug somewhere in Christian’s code anyways. I’ll get the data from the user first.

I reported the bug at feedback://showreport?report_id=54863 .

If you follow the documentation link, it redirects to Xojo.Core.InvalidArgumentException and the IDE gives me a compilation error:

Can't find a type with this name. Did you mean class Xojo.Core.InvalidArgumentException? Catch err As InvalidArgumentException

Turns out that there is no InvalidArgumentException, only a Xojo.Core.InvalidArgumentException and the documentation was already updated. Introspection has a FullName in addition to the Name property, which I don’t think is a good idea. But whatever. I can now send something to my user.

I’m willing to bet this is related to the class structure under the hood utilizing modules and such. The framework needs to know the object name but can then calculate the FullName using the object name and the parent namespace.