intel / rohd

The Rapid Open Hardware Development (ROHD) framework is a framework for describing and verifying hardware in the Dart programming language.
https://intel.github.io/rohd-website
BSD 3-Clause "New" or "Revised" License
374 stars 67 forks source link

Allow graceful error handling in `Simulator.throwException` #253

Open mkorbel1 opened 1 year ago

mkorbel1 commented 1 year ago

Motivation

As it is currently implemented, whenever there is an Exception thrown via Simulator.throwException, the Simulator.run function will always throw the first exception and halt any remaining progress through the run function. It also will always log a severe message. Some implications:

These seem like excessive limitations, and we should provide a method of gracefully handling issues from the Simulator.

=====

Additionally, if the Simulator is not actively running, then Simulator.throwException currently does nothing. This doesn't seem like proper behavior, and we should probably be immediately rethrowing in this case.

Desired solution

A way to configure the Simulator to gracefully handle error before defaulting to throwing it and incurring all of the downsides mentioned above. We can maybe look to the event handlers of StreamSubscription for inspiration: https://api.flutter.dev/flutter/dart-async/StreamSubscription-class.html

It should be possible to handle errors and still execute end-of-simulation actions.

Some thought needs to be put into how to log the messages in a way that is convenient for use cases like ROHD-VF.

======

We should immediately rethrow exceptions passed to Simulator.throwException if the simulation is not running.

Alternatives considered

No response

Additional details

No response

mkorbel1 commented 1 year ago

Additionally, if anything catches the Simulator's exceptions, the Simulation.simulationEnded never completes, which also means that any Simulator.reset() will never complete!