summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/leap.js2
-rw-r--r--app/assets/javascripts/srp/src/jqueryRest.js15
-rw-r--r--app/assets/javascripts/users.js6
3 files changed, 15 insertions, 8 deletions
diff --git a/app/assets/javascripts/leap.js b/app/assets/javascripts/leap.js
index c8fbcf5..c12a2d6 100644
--- a/app/assets/javascripts/leap.js
+++ b/app/assets/javascripts/leap.js
@@ -3,7 +3,7 @@
// add a bootstrap alert to the page via javascript.
//
function alert_message(msg) {
- $('#messages').append('<div class="alert alert-error"><a class="close" data-dismiss="alert">×</a><span>'+msg+'</span></div>');
+ $('#messages').append('<div class="alert alert-error"><a class="close" data-dismiss="alert">×</a><pre>'+msg+'</pre></div>');
}
ClientSideValidations.formBuilders['SimpleForm::FormBuilder'].wrappers.bootstrap = ClientSideValidations.formBuilders['SimpleForm::FormBuilder'].wrappers["default"];
diff --git a/app/assets/javascripts/srp/src/jqueryRest.js b/app/assets/javascripts/srp/src/jqueryRest.js
index 0c58eb2..437bd65 100644
--- a/app/assets/javascripts/srp/src/jqueryRest.js
+++ b/app/assets/javascripts/srp/src/jqueryRest.js
@@ -88,10 +88,17 @@ srp.remote = (function(){
// the http error response.
function error(xhr, text, thrown)
{
- if (xhr.responseText && xhr.responseText != "")
- srp.error($.parseJSON(xhr.responseText));
- else
- srp.error("Server did not respond.");
+ var message;
+ if (xhr.responseText && xhr.responseText != "") {
+ try {
+ message = $.parseJSON(xhr.responseText);
+ } catch (err) {
+ message = xhr.responseText;
+ }
+ } else {
+ message = "Server did not respond.";
+ }
+ srp.error(message);
};
return {
diff --git a/app/assets/javascripts/users.js b/app/assets/javascripts/users.js
index 3dae526..4b5198f 100644
--- a/app/assets/javascripts/users.js
+++ b/app/assets/javascripts/users.js
@@ -151,11 +151,11 @@
}
function extractErrors(message) {
- if ($.isPlainObject(message) && message.errors) {
- return message.errors;
+ if ($.isPlainObject(message)) {
+ return message.errors || { base: message.error };
} else {
return {
- base: (message.error || JSON.stringify(message))
+ base: message
};
}
}