Excel error handling

  • 15 July 2019
  • 4 replies
  • 194 views

Userlevel 2
Badge +4
When reading a table from an excel (and putting in wrong data) I get a pop-up in the UI stating what index it can't recognize and is therefore wrong, so something like this:

"ReadTable : Cell A2 in 'Excelfile': 'Wrong element' is not an existing element in the set 'Technical name of set'"

And I would like to use this information to make a specific pop-up for the end-user, so I can specify how to solve this error and also change the name of 'Technical name of set' to a name that they would recognize. So the exact element and index that are wrong, is stored somewhere, I would like to make use of this, but I can't find where to get this information.

4 replies

Userlevel 5
Badge +5
Hi @Guus Kattenbelt ,

The first article in this series will be helpful to you: https://how-to.aimms.com/C_Developer/Sub_Errors/index.html

You will be using the error handling functions included in AIMMS to specify a custom message to be displayed if an error occurs during a procedure run. Please review the content and if you still need help, you can reach out to the community.
Userlevel 2
Badge +4
Hi @mohansx,

Thanks for the answer. I had already read these articles and saw that you can indeed specify your own custom message. The only thing I cannot find, is how to use information about where the reading of the excel went wrong in the excel.

The standard message says something about the specific element that is not recognized as an index in a set. I would like to create my own error message, using this information (which element, which set/index), but I do not see this option in the error handling.
Userlevel 5
Badge +5
@Guus Kattenbelt , have you looked into the function errh::Message ? It looks like if an error occurs while reading in data from Excel, you want to provide a custom message to the user about which column / row in Excel caused the error.

You should be able to capture the error message triggered by the excel interfacing functions using errh::Message and then you would have to do some string manipulations to extract the cell location and insert it in your own message.
Userlevel 2
Badge +4
I have indeed looked at this functionality. But then I get the full message and indeed need to do string manipulations. I was hoping that I could just get the index and set that are causing the error, such that I do not need to do any string manipulations.

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator