Sparx Systems Forum

Enterprise Architect => Uml Process => Topic started by: amacara1 on November 09, 2023, 03:21:45 am

Title: Modeling C++ exceptions
Post by: amacara1 on November 09, 2023, 03:21:45 am
I thought of using Events to model C++ exceptions: an interruptible region (corresponding to C++ try) would have an "unlinked" receive event in it (corresponding to C++ catch) that out-flows into catch-body activities. BUT, events are added as links to a diagram and thus a diagram cannot hold multiple instances of a (same) event. So, different catches cannot be modeled.
I then thought of using Signal, but I cannot really differentiate between "sent"/"received" Signals (thrown/caught).

Do you have an example of how to model C++ exceptions, please?
Title: Re: Modeling C++ exceptions
Post by: PDC on January 10, 2024, 09:59:21 pm
If your Exception ('catch' Event) can occur at any point during the Activity, then can't you just place the entire Actvity (or as much as is required) within one InterruptibleRegion that catches that same Event? This would work as long as the Exception is in no way dependent on invoking your Try calls.
Title: Re: Modeling C++ exceptions
Post by: steubeat on February 22, 2024, 01:17:20 pm
You're right, directly modeling C++ exceptions with Events or Signals can be challenging due to their limitations. Here are some alternative approaches you can consider:

1. State Chart with Entry/Exit Actions:
2. Nested Activities with Error Handling:
3. Custom Extension:
Additional Tips:
Remember, the best approach depends on your specific modeling tool, the complexity of your C++ code, and your personal preferences. Evaluate each option and choose the one that best suits your needs. Source: fnaf games (https://fnaf-games.io) series