-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
While working on moving the markdown extension handling to the config, I noticed a few oddities with how errors and warnings are handled within the config. And taking a closer look at the code I see even more. I could just do a PR, but wanted some feedback on where you want to take this.
- I noticed that you need to hardcode the config key into any warnings (see this example) . This is bad as the same ConfigOption class could be used for more than one key (for example, if the Type or URL types raised a warning).
base.Config._validatedoes the right thing with errors and uses the current key (see L51). The same thing should happen for errors two lines above. - Why don't warnings actually use warnings? Why not follow the pattern used for errors and define a
ValidationWarningwhich subclasseswarnings.Warning. Then within the code callraise ValidationWarning('some message...')and inbase.Config._validateadd a catch for warnings in addition to the current catch for errors. Using the same API for both warnings and errors seems more sensible to me (and easier to remember). - Why are the errors being obscured? Only the message from the error is saved (see L51) and then later a new error is raised (see L148). Wouldn't it be better if the errors themselves were saved and re-raised? It would certainly help with debugging. Yes, I realize that if multiple errors were raised, only one could get re-raised. Not sure what the best solution is here for errors. Maybe log all the errors and then raise the first one? At least that way the user can work through them one at a time if the traceback is needed to figure out what went wrong.
Reactions are currently unavailable