Merge pull request #11562 from gavindsouza/site-conf-better-error
fix: Give better errors about corrupt site config
This commit is contained in:
commit
59e6929492
1 changed files with 11 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ from six import iteritems, binary_type, text_type, string_types, PY2
|
|||
from werkzeug.local import Local, release_local
|
||||
import os, sys, importlib, inspect, json
|
||||
from past.builtins import cmp
|
||||
|
||||
import click
|
||||
from faker import Faker
|
||||
|
||||
# public
|
||||
|
|
@ -226,12 +226,20 @@ def get_site_config(sites_path=None, site_path=None):
|
|||
if sites_path:
|
||||
common_site_config = os.path.join(sites_path, "common_site_config.json")
|
||||
if os.path.exists(common_site_config):
|
||||
config.update(get_file_json(common_site_config))
|
||||
try:
|
||||
config.update(get_file_json(common_site_config))
|
||||
except Exception as error:
|
||||
click.secho("common_site_config.json is invalid", fg="red")
|
||||
print(error)
|
||||
|
||||
if site_path:
|
||||
site_config = os.path.join(site_path, "site_config.json")
|
||||
if os.path.exists(site_config):
|
||||
config.update(get_file_json(site_config))
|
||||
try:
|
||||
config.update(get_file_json(site_config))
|
||||
except Exception as error:
|
||||
click.secho("{0}/site_config.json is invalid".format(local.site), fg="red")
|
||||
print(error)
|
||||
elif local.site and not local.flags.new_site:
|
||||
raise IncorrectSitePath("{0} does not exist".format(local.site))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue