Open PhilippvK opened 2 years ago
I'd not restrict what error handling we use. Assertions for unexpected conditions, when a user runs into this, it likely is a bug. Exceptions for errors that are expected during normal use. And we probably also have return values as errors for very common error conditions.
We should at least introduce an own exception type so that users can differentiate between errors by us and third party errors. I would then only add further types on demand whenever catching a category of errors becomes necessary.
Sure, we can omit stack traces for very clear errors.
Base for this will be implemented soon in v0.3.1
Currently error handling in MLonMCU is done in two different ways: • Raising
RuntimeError
s with a message • Assertions with optional messagesI had the idea to add custom error Types such as
RunError
,SessionError
,BackendError
, which should help to make some typical errors easier to understand. However I do not know what is the best approach as we also should not overdo it.Another related point is if we should omit stack-traces for user-facing interface. (i.e. if a model was not found inside an environment it would be enough to just print an error message)
We should also evaluate if
logging.error(msg)
might help us to clean up error messages.