From caeeac27dfabda3d642669ec34fd6d3aee89b348 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Mon, 18 Jan 2016 11:52:13 +0200 Subject: [PATCH] Verify the response status from the API The code was looking blindly in the response from the API, leading to a crash if there was an error instead of the expected success. (FT-1097) --- src/codacy/reporter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/codacy/reporter.py b/src/codacy/reporter.py index bb52b93..4119a5e 100755 --- a/src/codacy/reporter.py +++ b/src/codacy/reporter.py @@ -108,8 +108,11 @@ def upload_report(report, token, commit): logging.debug(r.content) r.raise_for_status() - message = json.loads(r.text)['success'] - logging.info(message) + response = json.loads(r.text) + try: + logging.info(response['success']) + except KeyError: + logging.error(response['error']) def run():