Error Handling not working in some cases

12 views
Skip to first unread message

laurent

unread,
May 3, 2019, 10:23:13 AM5/3/19
to AIMMS - The Modeling System
Dear AIMMS community,

I am trying to use the AIMMS error handling functionalities on my AIMMS 4.8 project.
I need to locally detect an error and to take some action if so.

The error I need to handle is when performing a put statement on an ASCII encoded file (F_test) as follow:

block
        PUT F_test,"è Â ó ù",/;

onerror PE_ErrorCatching do
if errh::Attribute(PE_ErrorCatching) then
LogMessage(1,ErrorCode,ModFunc,errh::Message(PE_ErrorCatching));
errh::MarkAsHandled(PE_ErrorCatching);
endif;
endblock;

The file F_test is encoding ASCII and therefore I get the following error message:
Cannot Convert the unicode character è into the output encoded ASCII

I don't know why but this error does not go through the onerror statement at all as if it was not detected as an error.
Replacing the put statement by a division by 0 is detected by the onerror statement and the error handling works as it should.
However the unicode/ASCII conversion error is not detected at all.

I then have two questions:
- Why is this error not detected ? (it may be a normal behavior)
- How to deal with this error without changing the encoding of the files ? is there a way to convert an UTF-8 string into an ACII string  within aimms before the put statement and to try the error handler on this strin to string conversion instead on the put statement ?

Thank you in advance for your Help,

Kind Regards,

Laurent


Reply all
Reply to author
Forward
0 new messages