jbernard / dotfiles

Dotfile management made easy
https://pypi.org/project/dotfiles/
Other
579 stars 61 forks source link

Use built-in exceptions #59

Open miedzinski opened 8 years ago

miedzinski commented 8 years ago

It's only a matter of coding style and isn't that important, but there shouldn't be unnecesary exceptions created. I think OSError is perfectly fine for all exceptions defined. This change shouldn't break anything, because I doubt anyone is using dotfiles as library. If you don't think these exceptions should be removed, atleast subclass DotfileException with OSError.

jbernard commented 8 years ago

Thanks for the thoughts. Just curious, is this coding style documented somewhere, or just your preference? You're saying remove the defined exceptions in dotfiles/exceptions.py and just use OSError, what about errno in that case? What I liked about the exceptions is that the code is very readable at the point of raise, I'm not passing in error strings, or formatting anything, just the dotfile name and the exception class does the rest - that seemed elegant to me. Can you post a snippet of what you had in mind? I'd love to remove them entirely as long as I can keep things readable in the main functions.

Cheers

prologic commented 8 years ago

FWIW I think it's fine to raise custom exceptions like this. It's not always a good idea in the case of librariy code but as this is a tool/application I think it's fine.