Commit f29d02bf by Braden MacDonald

Catch validation errors raised during studio editing

parent 9aae3693
...@@ -81,6 +81,10 @@ function StudioEditableXBlockMixin(runtime, element) { ...@@ -81,6 +81,10 @@ function StudioEditableXBlockMixin(runtime, element) {
if (jqXHR.responseText) { // Is there a more specific error message we can show? if (jqXHR.responseText) { // Is there a more specific error message we can show?
try { try {
message = JSON.parse(jqXHR.responseText).error; message = JSON.parse(jqXHR.responseText).error;
if (typeof message === "object" && message.messages) {
// e.g. {"error": {"messages": [{"text": "Unknown user 'bob'!", "type": "error"}, ...]}} etc.
message = $.map(message.messages, function(msg) { return msg.text; }).join(", ");
}
} catch (error) { message = jqXHR.responseText.substr(0, 300); } } catch (error) { message = jqXHR.responseText.substr(0, 300); }
} }
runtime.notify('error', {title: gettext("Unable to update settings"), message: message}); runtime.notify('error', {title: gettext("Unable to update settings"), message: message});
......
...@@ -26,6 +26,8 @@ from xblockutils.resources import ResourceLoader ...@@ -26,6 +26,8 @@ from xblockutils.resources import ResourceLoader
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
loader = ResourceLoader(__name__) loader = ResourceLoader(__name__)
# Classes ###########################################################
class FutureFields(object): class FutureFields(object):
""" """
...@@ -35,6 +37,7 @@ class FutureFields(object): ...@@ -35,6 +37,7 @@ class FutureFields(object):
self._new_fields_dict = new_fields_dict self._new_fields_dict = new_fields_dict
self._blacklist = newly_removed_fields self._blacklist = newly_removed_fields
self._fallback_obj = fallback_obj self._fallback_obj = fallback_obj
def __getattr__(self, name): def __getattr__(self, name):
try: try:
return self._new_fields_dict[name] return self._new_fields_dict[name]
......
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