XML Error ignore and skip

  1. 3 months ago

    Aurelian N

    Jan 28 Pre-Release Testers, Xojo Pro

    Hello ,

    so I have a project that reads a bunch of .xml files and parses the data from them, it seems that on some of them there are errors and I want when I catch something like this to skip over and ignore the error and jump to the next file.

    Try
      Xml.LoadXml(f)
    Catch err As KeyNotFoundException
      P5FVal = P5FVal + 1
    End Try

    Code is something like above, the problem is that in the project when I run in Xojo I get error and stopping the code on

    Xml.LoadXml(f)

    then it stops and then I have to press resume so that I can run the rest.

    By doing that it seems that the code runs again and all is processed if no other errors.

    IS there a way to ignore that and skip the file ? even thinking to move the file in another folder like corruptedFiles or something like that .

    Thanks.

  2. Jean-Yves P

    Jan 28 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    may be it's because you have "break on exception" checked under the project menu ?

  3. Aurelian N

    Jan 28 Pre-Release Testers, Xojo Pro

    @Jean-YvesPochez may be it's because you have "break on exception" checked under the project menu ?

    Good point , I will have to check on that .

    Thanks.

  4. Tim P

    Jan 28 Pre-Release Testers Austin, TX
    Edited 3 months ago

    Jean-Yves is likely correct, and you can disable it on a method by method basis with #pragma BreakOnExceptions false.
    http://docs.xojo.com/Pragma_Directives

    (this lets you keep that very useful feature on, but disable it for methods in which you do expect and handle them)

or Sign Up to reply!