base16-builder-python icon indicating copy to clipboard operation
base16-builder-python copied to clipboard

distinguish between missing templates and schemes

Open knezi opened this issue 5 years ago • 2 comments

When there's not template or scheme file, we get a general error saying not all resources present. Instead, it'd be nice if it reported what is missing. I suggest creating two children of LookupError and return a corresponding error. What do you think? I'm ready to implement this.

knezi avatar Jul 21 '20 15:07 knezi

Hello hello! Sorry for the late reply and thank you for the suggestion. We can definitely distinguish between those two error types, however I don't think it's necessary to subclass LookupError. Instead, I think it would be a good idea to clean up the error printing code so that error messages are just passed along together with the exception instance.

So instead of this

def something():
    raise LookupError

try:
    something()
except LookupError:
    print("specific error message")

we should do this:

def something():
    raise LookupError("specific error message")

try:
    something()
except LookupError as exc:
    print(exc.msg)

The err_print function should be adapted to this end as well. Would you be interested in implementing this as well? If it's a bit too far removed from what you had in mind, I'd gladly do it myself (might take a bit though).

Pu-Anlai avatar Jul 26 '20 12:07 Pu-Anlai

Yes, this is a much better solution. I'll implement it. It just might take a while. I'll get back to you once I have something.

knezi avatar Jul 27 '20 07:07 knezi