question

Gui Vaccaro avatar image
0 Likes"
Gui Vaccaro asked Jason Lightfoot commented

Disabling silent error handling?

Hello,

When FlexSim runs, several exceptions are silent to the user. For instance, if by code one tries to find or create an object with an invalid name or if find is used with a mistyped path. Is there a way to make these exceptions visible to the user during execution? Where could I find additional explanation about how to set it up, please?

This will facilitate model debugging and troubleshooting.

Thank you!

FlexSim 25.0.2
system consoleoutput consolecompiler consoleechoerror reporting
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Jason Lightfoot commented

The two examples you give are working as intended.

Object.create() does throw an exception if you pass in an invalid class name.

Model.find() does not throw an exception, but it returns null if the object doesn't exist. This allows you to check if objects exist without exceptions being thrown.

treenode object = Model.find("DoesntExist");
if (object)
...
else
...


· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Gui Vaccaro avatar image Gui Vaccaro commented ·

Hi, @Matthew Gillespie ,

Thank you, I am aware of that. This is no bug report. This is a question about error reporting (echoing) during modeling/programming.

Many environments have this kind of switch so programmers can more easily detect error in their codes, as I am sure you are aware. Testing via code every result of a create or find makes code cumbersome to read, especially when one is sure an object should be found. As many people including me make typing and programming error, having a simple message coming out from the System/Compiler console indicating an object that was supposed to be created or found was not (and being able to turn this echo on/off) would help code development. I hope I could explain better what I was looking for.

Anyway, your answer is clear and that feature does not exist in FlexSim.

Thank you.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Gui Vaccaro commented ·

Gui, the developers decide what constitutes an exception - if you want to have custom exceptions you'll need to write user commands that you use instead of the standard methods and then you can detect issues and print them to the various consoles or your own gui or text file as custom exceptions of your own.

As a tip regarding your example, I would say you should not be using Model.find() with strings extensively in your code anyway - the preferred technique is to use pointers that you have stored as labels, arrays, lists or couplings - then if you choose to rename objects the references will not be broken.


1 Like 1 ·
Gui Vaccaro avatar image Gui Vaccaro Jason Lightfoot ♦♦ commented ·
Hi, @Jason Lightfoot , your comment is GOLD!

This is exactly what I am looking for, but most of the examples and answers in this forum do exactly what we should avoid (using strings). That leads users like me to mimic a non-recommended procedure.
If possible, could you send me some directions about how to set this up (I did not see that clearly in the help/tutorials; probably I missed it).
Thank you once again!

0 Likes 0 ·
Show more comments