Skip to content

Commit

Permalink
Merge pull request #323 from edx/aj/tnl2324-add-log-in-xblocksaveerro…
Browse files Browse the repository at this point in the history
…r-exception

Adding message in XBlockSaveError Exception
  • Loading branch information
awaisdar001 committed Oct 26, 2015
2 parents 111935c + 0c1f796 commit a20c70f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ David Bodor <david.gabor.bodor@gmail.com>
Dhruv Baldawa <dhruvbaldawa@gmail.com>
Matjaz Gregoric <mtyaka@gmail.com>
Adam Palay <adam@edx.org>
Awais Jibran <awaisdar001@gmail.com>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 3rd-party needs
pyyaml
lxml
requests
webob
Expand Down
4 changes: 2 additions & 2 deletions xblock/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class XBlockSaveError(Exception):
"""
Raised to indicate an error in saving an XBlock
"""
def __init__(self, saved_fields, dirty_fields):
def __init__(self, saved_fields, dirty_fields, message=None):
"""
Create a new XBlockSaveError
Expand All @@ -30,7 +30,7 @@ def __init__(self, saved_fields, dirty_fields):
`dirty_fields` - a set of fields that were left dirty after the save
"""
# Exception is an old-style class, so can't use super
Exception.__init__(self)
Exception.__init__(self, message)

self.saved_fields = saved_fields
self.dirty_fields = dirty_fields
Expand Down
3 changes: 2 additions & 1 deletion xblock/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ def force_save_fields(self, field_names):
fields.remove(field)
# if the field was dirty, delete from dirty fields
self._reset_dirty_field(field)
raise XBlockSaveError(saved_fields, fields)
msg = 'Error saving fields {}'.format(save_error.saved_field_names)
raise XBlockSaveError(saved_fields, fields, msg)

# Remove all dirty fields, since the save was successful
for field in fields:
Expand Down

0 comments on commit a20c70f

Please sign in to comment.