Improve error handling for missing files #2551
Conversation
c5284ef
to
357b54e
Compare
`os.path.exists` doesn't allow us to distinguish between permissions errors and the path actually not existing, which repeatedly confuses people. It also means that we try to overwrite existing key files, which is super-confusing. (cf issues #2455, #2379). Use os.stat instead. Also, don't recomemnd the the use of --generate-config, which screws everything up if you're using debian (cf #2455).
357b54e
to
abd502b
Compare
I'm a bit scared that we're losing some helpful hints for people tying to use python directly, or do we have error messages elsewhere if a config file isn't specified? Generally we can rewrite the help text in the debian build where appropriate (e.g. we already remove references to |
def check_file(cls, file_path, config_name): | ||
if file_path is None: | ||
raise ConfigError( | ||
"Missing config for %s." | ||
" You must specify a path for the config file. You can " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this text was completely bogus, afaict. This function is called to check that files referenced from the config file exist, rather than the config file itself.
if no config file is specified, you hit synapse/synapse/config/_base.py Line 319 in 9097f3f
Of all the things caught by the messages I'm removing, I'm unconvinced that --generate-config will solve any of them rather than making everything worse. |
Ok, then that works for me |
os.path.exists
doesn't allow us to distinguish between permissions errors andthe path actually not existing, which repeatedly confuses people. It also means
that we try to overwrite existing key files, which is super-confusing. (cf
issues #2455, #2379). Use os.stat instead.
Also, don't recomemnd the the use of --generate-config, which screws everything
up if you're using debian (cf #2455).