jtleider / censusdata

Download data from Census API
MIT License
139 stars 29 forks source link

[feature] Display error messages with raise statements, instead of print() #21

Closed adunmore closed 3 years ago

adunmore commented 3 years ago

When errors are raised, the accompanying messages are output via print statements. This means that messages are printed at the top of the stack trace, where they're relatively hidden. Rather, error messages should be printed with the raise statement, as in raise SomeError('Some error message')

In my experience, this is especially confusing to less-experienced Python users, who aren't in the habit of scrolling through a stack trace, and so are unlikely to find these error messages.

The current approach:

print('Some error message')
raise SomeError

The suggested approach:

raise SomeError('Some error message')
adunmore commented 3 years ago

I suppose this isn't quite a feature request? More of a fix... Anyway, see my PR. I'm happy to make any changes to it!

jtleider commented 3 years ago

Thanks for the suggestion! I have implemented this in the most recent commit.