Warm tip: This article is reproduced from serverfault.com, please click

Try/Catch does not work on conversion error, while importing data from excel in X++

发布于 2021-01-25 08:58:51

I am trying to import data from excel to my journal, but if there is a conversion error, it just blocks my journal. I want to make try/catch exception, but it does not work.

My code looks like this:

try
{
    [My insert code]
}
catch (Exception::Error)
{                    
    throw error("error here");
}

Error looks like this:

Error executing code: Wrong type of argument for conversion function.

And first suggestion probably will be "Fix the conversion code", but it wouldnt resolve my problem... Does anyone know why my catch block does not see that error?
I tried to find exception for conversion errors, but there is like 0 information about it on internet.

Questioner
Kristers Homičs
Viewed
0
Jonathan Bravetti 2021-01-25 19:30:00

Try without this (Exception::Error) because it is probably that your code does not give an Error exception.

try
{
    [My insert code]
}
catch
{                    
    throw error("error here");
}