Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65881633/try-catch-does-not-work-on-conversion-error-while-importing-data-from-excel-in

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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");
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...