log 5xx errors
Also, fix console.log usage.
This commit is contained in:
parent
a29393ee3f
commit
306d2d9f9e
@ -47,7 +47,11 @@ define(["app/lib/promise"], function(Q) {
|
|||||||
document.cookie = cookie;
|
document.cookie = cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({status: xhr.status, body: xhr.responseText});
|
if (xhr.status >= 500) {
|
||||||
|
reject(xhr.body);
|
||||||
|
} else {
|
||||||
|
resolve({status: xhr.status, body: xhr.responseText});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -88,7 +92,13 @@ define(["app/lib/promise"], function(Q) {
|
|||||||
var modify = function(id, data) {
|
var modify = function(id, data) {
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
curl("PUT", endpoint + "/id/" + id, JSON.stringify(data), function (rv) {
|
curl("PUT", endpoint + "/id/" + id, JSON.stringify(data), function (rv) {
|
||||||
deferred.resolve(JSON.parse(rv.body));
|
if (rv.status === 403) {
|
||||||
|
deferred.reject("Not authorized to modify this comment!");
|
||||||
|
} else if (rv.status === 200) {
|
||||||
|
deferred.resolve(JSON.parse(rv.body));
|
||||||
|
} else {
|
||||||
|
deferred.reject(rv.body);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,8 @@ define(function() {
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var stderr = function(text) { console.log(text); };
|
||||||
|
|
||||||
var Promise = function() {
|
var Promise = function() {
|
||||||
this.success = [];
|
this.success = [];
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
@ -12,7 +14,7 @@ define(function() {
|
|||||||
if (onError) {
|
if (onError) {
|
||||||
this.errors.push(onError);
|
this.errors.push(onError);
|
||||||
} else {
|
} else {
|
||||||
this.errors.push(console.log);
|
this.errors.push(stderr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user