Try/catch failing for InvalidArgumentException

  1. 7 months ago

    Beatrix W

    6 Feb 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    Got an error report from a user regarding an InvalidArgumentException

    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

    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.

  2. Markus W

    6 Feb 2019 Pre-Release Testers #JeSuisHuman New Zealand, Auc...
    Edited 7 months ago

    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?

  3. Beatrix W

    7 Feb 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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.

  4. Beatrix W

    7 Feb 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    And a bare

    try
    catch err as InvalidArgumentException
    end try

    also doesn't work and gives the same error.

  5. Markus W

    7 Feb 2019 Pre-Release Testers #JeSuisHuman New Zealand, Auc...

    @Beatrix W 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.

    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?

  6. Beatrix W

    7 Feb 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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 Case #54863 .

  7. Jonathan E

    7 Feb 2019 Pre-Release Testers, Xojo Pro Las Vegas, NV

    @Beatrix Willius The docs says it's an InvalidArgumentException and not a Xojo.Core one: http://docs.xojo.com/InvalidArgumentException

    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
  8. Beatrix W

    8 Feb 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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.

  9. Jonathan E

    8 Feb 2019 Pre-Release Testers, Xojo Pro Las Vegas, NV

    @Beatrix Willius Introspection has a FullName in addition to the Name property

    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.

or Sign Up to reply!