Commit 1d59979e by Will Daly

Remove deprecated Exception.message calls; fix TIM-497

parent 2e668da1
...@@ -163,7 +163,7 @@ def create_assessment( ...@@ -163,7 +163,7 @@ def create_assessment(
try: try:
option_ids = rubric.options_ids(options_selected) option_ids = rubric.options_ids(options_selected)
except InvalidOptionSelection as ex: except InvalidOptionSelection as ex:
msg = _("Selected options do not match the rubric: {error}").format(error=ex.message) msg = _("Selected options do not match the rubric: {error}").format(error=ex)
raise PeerAssessmentRequestError(msg) raise PeerAssessmentRequestError(msg)
scorer_workflow = PeerWorkflow.objects.get(submission_uuid=scorer_submission_uuid) scorer_workflow = PeerWorkflow.objects.get(submission_uuid=scorer_submission_uuid)
...@@ -192,7 +192,12 @@ def create_assessment( ...@@ -192,7 +192,12 @@ def create_assessment(
peer_serializer = AssessmentSerializer(data=peer_assessment) peer_serializer = AssessmentSerializer(data=peer_assessment)
if not peer_serializer.is_valid(): if not peer_serializer.is_valid():
raise PeerAssessmentRequestError(peer_serializer.errors) msg = (
u"An error occurred while serializing "
u"the peer assessment associated with "
u"the scorer's submission UUID {}."
).format(scorer_submission_uuid)
raise PeerAssessmentRequestError(msg)
assessment = peer_serializer.save() assessment = peer_serializer.save()
......
...@@ -322,7 +322,7 @@ def get_training_example(submission_uuid, rubric, examples): ...@@ -322,7 +322,7 @@ def get_training_example(submission_uuid, rubric, examples):
logger.exception( logger.exception(
"Could not deserialize training examples for submission UUID {}".format(submission_uuid) "Could not deserialize training examples for submission UUID {}".format(submission_uuid)
) )
raise StudentTrainingRequestError(ex.message) raise StudentTrainingRequestError(ex)
except sub_api.SubmissionNotFoundError as ex: except sub_api.SubmissionNotFoundError as ex:
msg = _(u"Could not retrieve the submission with UUID {}").format(submission_uuid) msg = _(u"Could not retrieve the submission with UUID {}").format(submission_uuid)
logger.exception(msg) logger.exception(msg)
......
""" """
Errors for the peer assessment. Errors for the peer assessment.
""" """
import copy
class PeerAssessmentError(Exception): class PeerAssessmentError(Exception):
...@@ -21,10 +20,7 @@ class PeerAssessmentRequestError(PeerAssessmentError): ...@@ -21,10 +20,7 @@ class PeerAssessmentRequestError(PeerAssessmentError):
information which does not allow the request to be processed. information which does not allow the request to be processed.
""" """
pass
def __init__(self, field_errors):
super(PeerAssessmentRequestError, self).__init__(repr(field_errors))
self.field_errors = copy.deepcopy(field_errors)
class PeerAssessmentWorkflowError(PeerAssessmentError): class PeerAssessmentWorkflowError(PeerAssessmentError):
......
...@@ -77,9 +77,9 @@ class PeerAssessmentMixin(object): ...@@ -77,9 +77,9 @@ class PeerAssessmentMixin(object):
# Emit analytics event... # Emit analytics event...
self._publish_peer_assessment_event(assessment) self._publish_peer_assessment_event(assessment)
except PeerAssessmentRequestError as ex: except PeerAssessmentRequestError:
return {'success': False, 'msg': ex.message} return {'success': False, 'msg': _(u"Your peer assessment could not be submitted.")}
except PeerAssessmentInternalError as ex: except PeerAssessmentInternalError:
msg = _("Internal error occurred while creating the assessment") msg = _("Internal error occurred while creating the assessment")
logger.exception(msg) logger.exception(msg)
return {'success': False, 'msg': msg} return {'success': False, 'msg': msg}
......
...@@ -139,10 +139,10 @@ class SelfAssessmentMixin(object): ...@@ -139,10 +139,10 @@ class SelfAssessmentMixin(object):
# After we've created the self-assessment, we need to update the workflow. # After we've created the self-assessment, we need to update the workflow.
self.update_workflow_status() self.update_workflow_status()
except self_api.SelfAssessmentRequestError as ex: except self_api.SelfAssessmentRequestError as ex:
msg = _(u"Could not create self assessment: {error}").format(error=ex.message) msg = _(u"Could not create self assessment: {error}").format(error=ex)
return {'success': False, 'msg': msg} return {'success': False, 'msg': msg}
except workflow_api.AssessmentWorkflowError as ex: except workflow_api.AssessmentWorkflowError as ex:
msg = _(u"Could not update workflow: {error}").format(error=ex.message) msg = _(u"Could not update workflow: {error}").format(error=ex)
return {'success': False, 'msg': msg} return {'success': False, 'msg': msg}
else: else:
return {'success': True, 'msg': u""} return {'success': True, 'msg': u""}
...@@ -161,7 +161,7 @@ class StudentTrainingMixin(object): ...@@ -161,7 +161,7 @@ class StudentTrainingMixin(object):
except (student_training.StudentTrainingRequestError, student_training.StudentTrainingInternalError) as ex: except (student_training.StudentTrainingRequestError, student_training.StudentTrainingInternalError) as ex:
return { return {
'success': False, 'success': False,
'msg': _(u"Your scores could not be checked: {error}.").format(error=ex.message) 'msg': _(u"Your scores could not be checked: {error}.").format(error=ex)
} }
except: except:
return { return {
......
...@@ -56,10 +56,10 @@ class StudioMixin(object): ...@@ -56,10 +56,10 @@ class StudioMixin(object):
update_from_xml_str(self, data['xml'], validator=validator(self)) update_from_xml_str(self, data['xml'], validator=validator(self))
except ValidationError as ex: except ValidationError as ex:
return {'success': False, 'msg': _('Validation error: {error}').format(error=ex.message)} return {'success': False, 'msg': _('Validation error: {error}').format(error=ex)}
except UpdateFromXmlError as ex: except UpdateFromXmlError as ex:
return {'success': False, 'msg': _('An error occurred while saving: {error}').format(error=ex.message)} return {'success': False, 'msg': _('An error occurred while saving: {error}').format(error=ex)}
else: else:
return {'success': True, 'msg': _('Successfully updated OpenAssessment XBlock')} return {'success': True, 'msg': _('Successfully updated OpenAssessment XBlock')}
...@@ -87,7 +87,7 @@ class StudioMixin(object): ...@@ -87,7 +87,7 @@ class StudioMixin(object):
# We do not expect `serialize_content` to raise an exception, # We do not expect `serialize_content` to raise an exception,
# but if it does, handle it gracefully. # but if it does, handle it gracefully.
except Exception as ex: except Exception as ex:
msg = _('An unexpected error occurred while loading the problem: {error}').format(error=ex.message) msg = _('An unexpected error occurred while loading the problem: {error}').format(error=ex)
logger.error(msg) logger.error(msg)
return {'success': False, 'msg': msg, 'xml': u''} return {'success': False, 'msg': msg, 'xml': u''}
else: else:
......
...@@ -207,7 +207,7 @@ def validate_dates(start, end, date_ranges): ...@@ -207,7 +207,7 @@ def validate_dates(start, end, date_ranges):
try: try:
resolve_dates(start, end, date_ranges) resolve_dates(start, end, date_ranges)
except (DateValidationError, InvalidDateFormat) as ex: except (DateValidationError, InvalidDateFormat) as ex:
return (False, ex.message) return (False, unicode(ex))
else: else:
return (True, u'') return (True, u'')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment