Hi.
I'm calling an XMLPort from a codeunit and I want to catch cases where the XMLPort fails because of a badly formed file, a condition I haven't forseen, etc.
So I have this:
IF NOT XML_Port.IMPORT THEN BEGIN
ErrorText := GETLASTERRORTEXT;
CLEARLASTERROR;
END;
MESAGE(ErrorText);
The trouble is, ErrorText (returned by GETLASTERRORTEXT) is always empty, even in cases where a straight call to the XMLPort (no IF at the front) produces a proper NAV error message on the screen.
Has anyone got a suggestion why I can't get the error text properly?
Thanks in advance.
Bob
Answers
your CU is going to look like this
onRun()
XML_Port.IMPORT;
your code will look like this
IF NOT MyCodeUnit.run THEN BEGIN
ErrorText := GETLASTERRORTEXT;
CLEARLASTERROR;
END;
MESAGE(ErrorText);
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Did that, and I think I'm good.
When the XMLport is called on a mal-formed XML file, I am now getting a proper (well, for NAV) error message on the screen, the code continues, and the error text is availble for logging just as I wanted.
I find it strange that the XML error makes it to the screen, but since this will be running under NAS I'm assuming that GUI error message will end up in the event log and not affect the processing.
Thank's again.
Bob
[/b]
Most customers prefer to send an email or write it to a log table so that the can go and see it instead of logging where nas is to trouble shoot the problem.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I already have everything possible going to a plain-text log file, and I have email alerts going out reporting any errors in the imported data. (That's always the first code I write - I consider it essential for both development/debugging, and in production.)
This was all fine if the XMLport.IMPORT completed, but what was missing was the ability to report cases where the XMLport choked on a badly formed file and all processing ground to a halt. Now I have that covered as well.
Thank's again
Bob
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Any ideas how to handle XMLPort malformed file error in case when XMLport is used as parameter for Web service?
In NAV we have just Codeunit.Run where we can handle these type of requests.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/