git-afsantos / haros

H(igh) A(ssurance) ROS - Static analysis of ROS application code.
MIT License
190 stars 37 forks source link

Provide better error messages #49

Closed git-afsantos closed 2 months ago

git-afsantos commented 5 years ago

For most errors, the user is presented a stack trace of the corresponding exception. As suggested in #41, better error messages should be provided.

To accomplish this, a central error reporting utility might be a good idea, so as to avoid spreading print all over the place. The util.py script is a good candidate for this.

It might also be worth it to change the current logging behaviour. Use two loggers, instead of one. One, by default, prints everything from INFO and above to the log file, unless --debug is set, in which case DEBUG is also logged. The second logger is used with a better formatting to print messages to the user.

Another interesting idea, while messing with error handling, is to define custom exit codes, so that failures are better identified. See this SO answer or this page for ideas of standard and unallocated error codes.

git-afsantos commented 5 years ago

This line may return None if the provided project file does not contain any YAML documents.

This leads to this line raising

AttributeError: 'NoneType' object has no attribute 'get'

git-afsantos commented 5 years ago

https://github.com/git-afsantos/haros/issues/72#issuecomment-519729404

The documentation did not mention that the plugin name must be preceded by "harosplugin", and the error message made it sound like no plugins (at all) were found instead of just this particular plugin not being found.

Try to distinguish between not finding any plugins and simply not finding any for the user-provided names.