avoid database error when recording task exception

This commit is contained in:
jsa
2015-01-21 09:21:54 -05:00
parent 0f0b2cbd49
commit ace2bffae6
3 changed files with 26 additions and 2 deletions

View File

@@ -143,7 +143,7 @@ class CourseRerunUIStateManager(CourseActionUIStateManager):
self.update_state(
course_key=course_key,
new_state=self.State.FAILED,
message=traceback.format_exc(),
message=traceback.format_exc()[-self.model.MAX_MESSAGE_LENGTH:], # truncate to fit
)

View File

@@ -83,13 +83,17 @@ class CourseActionUIState(CourseActionState):
"""
abstract = True
# WARNING - when you edit this value, you're also modifying the max_length
# of the `message` column (see below)
MAX_MESSAGE_LENGTH = 1000
# FIELDS
# Whether or not the status should be displayed to users
should_display = models.BooleanField()
# Message related to the status
message = models.CharField(max_length=1000)
message = models.CharField(max_length=MAX_MESSAGE_LENGTH)
# Rerun courses also need these fields. All rerun course actions will have a row here as well.