Skip to content

Commit

Permalink
add log when failed on exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyqin committed Oct 24, 2017
1 parent e726710 commit e1b3816
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions testcube/core/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def handler(self, request, pk=None):
return Response(data='Result has been saved.')

except Exception as e:
logger.exception('Failed to handle reset result: {}'.format(pk))
instance.reset_status = 3 # failed
instance.save()
return Response(data=str(e.args), status=400)
3 changes: 3 additions & 0 deletions testcube/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django import forms

from testcube.settings import logger
from .models import ResultAnalysis, Issue, TestResult, ResetResult
from ..runner.models import Task

Expand Down Expand Up @@ -141,6 +142,8 @@ def _parse_command(command, result):
cmd = command.format(result=result)
return cmd, None
except Exception as e:
logger.exception('Failed to parse command: {}'.format(command))

message = 'while parsing command "{}" due to {}: {}'.format(
command, type(e).__name__, e.args)
return command, message
1 change: 1 addition & 0 deletions testcube/runner/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ def handler(self, request, pk=None):
return Response(data={'status': status, 'message': message})

except Exception as e:
logger.exception('Failed to handle task: {}'.format(pk))
return Response(data=str(e.args), status=400)
3 changes: 2 additions & 1 deletion testcube/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def append_json(origin_txt, field, value):
try:
obj = json.loads(origin_txt)
except:
logging.warning('Cannot parse to json: {}'.format(origin_txt))
from testcube.settings import logger
logger.warning('Cannot parse to json: {}'.format(origin_txt))
obj = {}

if field in obj:
Expand Down

0 comments on commit e1b3816

Please sign in to comment.