tum-ei-eda / mlonmcu

Tool for the deployment and analysis of TinyML applications on TFLM and MicroTVM backends
Apache License 2.0
29 stars 12 forks source link

Discussion on custom error types #14

Open PhilippvK opened 2 years ago

PhilippvK commented 2 years ago

Currently error handling in MLonMCU is done in two different ways: • Raising RuntimeErrors with a message • Assertions with optional messages

I 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.

rafzi commented 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.

PhilippvK commented 1 year ago

Base for this will be implemented soon in v0.3.1