Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more kindly error #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lambda_uploader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
u's3_bucket': None, u's3_key': None, u'runtime': 'python2.7',
u'variables': {}, u'subscription': {}, u'tracing': {}}

LAMBDA_JSON = 'lambda.json'


class Config(object):
def __init__(self, pth, config_file=None, role=None, variables=None):
Expand Down Expand Up @@ -186,13 +188,16 @@ def _load_config(self, lambda_file=None):
raise Exception("%s not a valid function directory" % self._path)

if not lambda_file:
lambda_file = path.join(self._path, 'lambda.json')
lambda_file = path.join(self._path, LAMBDA_JSON)

if not path.isfile(lambda_file):
raise Exception("%s not a valid configuration file" % lambda_file)

with open(lambda_file) as config_file:
self._config = json.load(config_file)
try:
self._config = json.load(config_file)
except json.decoder.JSONDecodeError:
raise Exception("%s not a valid json file" % LAMBDA_JSON)

def __getattr__(self, key):
if key in self._config:
Expand Down