Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catkin should not suppress unexpected python stacktraces #373

Closed
tkruse opened this issue Mar 4, 2013 · 2 comments
Closed

catkin should not suppress unexpected python stacktraces #373

tkruse opened this issue Mar 4, 2013 · 2 comments
Assignees

Comments

@tkruse
Copy link
Member

tkruse commented Mar 4, 2013

In catkin/python/catkin/builder.py, line 608:

        except Exception as e:
            cprint(
                '@{rf}@!<==@| ' +

catching all of Exception is generally bad practice,
http://docs.python.org/2/howto/doanddont.html
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Exceptions

and it leads to mysterious error messages like here:
http://answers.ros.org/question/56962/catkin-bfl-build-fails-nonetype-object-has-no-attribute-rfind/

Instead, only a subset of exceptions should be handled, such as

        except (IOError, ImportError, ValueError) as e:

It would be even better if catkin defined an own Exception class that library code can raise when the user is supposed to only see the message.

Helping users fix errors themselves and report with stack traces helps us all maintain catkin and catkin packages with less effort.

@dirk-thomas
Copy link
Member

Catching all exceptions makes perfect sense in some scenarios. I.e. in this one because the builder module want to print a reasonable error message which the user can read (as argued before in other issues).

The committed patch will print the full stacktrace to provide more information in case of errors.

@ghost ghost assigned dirk-thomas Mar 5, 2013
@tkruse
Copy link
Member Author

tkruse commented Mar 5, 2013

The patch makes things much better already, so I won't complain. But catching Exception in a non-UI function remains a bad idea, it invalidates the function as a library call for other tools. So If this was done in catkin_make or catkin_make_isolated (or some wrapper function without algorithmic value just for user interaction), I would not flag it as a style issue.

cwecht pushed a commit to cwecht/catkin that referenced this issue Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants