Commit 68ac7bdb authored by Łukasz Nowak's avatar Łukasz Nowak

erp5_web_monitoring: Review error handling

By using pattern r'push.*undef' files has been selected, and for each obvious
place error handling has been delegated to global error handling system and all
places found with silent catching errors has been marked with XXX-catchall with
optional explanation.
parent 6bcf0f95
......@@ -181,9 +181,6 @@
settings_queue
.push(function () {
return gadget.jio_put(id, config);
})
.push(undefined, function (error) {
throw error;
});
}
if (validate_result) {
......@@ -594,6 +591,7 @@
return getInstanceOPMLListFromMaster(gadget, select_limit);
})
.push(undefined, function () {
// XXX-catchall: This shall be another branch of promise above to not be catch-all like it's now
gadget.state.message
.innerHTML = notify_msg_template({
status: 'error',
......@@ -611,9 +609,6 @@
push_queue
.push(function () {
return gadget.jio_put(opml_dict.url, opml_dict);
})
.push(undefined, function (error) {
throw error;
});
}
......@@ -623,6 +618,7 @@
return push_queue;
})
.push(undefined, function () {
// XXX-catchall
gadget.state.message
.innerHTML = notify_msg_template({
status: 'error',
......
......@@ -70,6 +70,7 @@
.get(gadget.property_dict.monitor_process_state);
})
.push(undefined, function () {
// XXX-catchall
return gadget.notifySubmitted({
message: "Error: Failed to download data files!",
status: "error"
......@@ -223,6 +224,7 @@
return gadget.property_dict.jio_gadget
.get(gadget.property_dict.monitor_process_state)
.push(undefined, function () {
// XXX-catchall
return gadget.notifySubmitted({
message: "Error: Failed to download data files!",
status: "error"
......
......@@ -24,6 +24,7 @@
var resource_key = gadget.property_dict.resource_dict[key];
return gadget.property_dict.jio_gadget.get(resource_key)
.push(undefined, function () {
// XXX-catchall
return gadget.notifySubmitted({
message: "Error: Failed to download resource file '" + resource_key +
"' from URL: " + gadget.state.opml_outline.url,
......
......@@ -210,9 +210,10 @@
gadget.state.promise.source + ".history"
)
.push(undefined, function (error) {
if (error.name === "cancel") {
if (error.name === "cancel") { // XXX-catchall: better error instanceof RSVP.CancellationError
return undefined;
}
// XXX-catchall
return gadget.notifySubmitted({
status: "error",
message: "Failed to get promise history content! \n" +
......
......@@ -63,10 +63,7 @@
})
.declareMethod('repair', function () {
var storage = this.props.jio_storage;
return storage.repair.apply(storage, arguments)
.push(undefined, function (error) {
throw error;
});
return storage.repair.apply(storage, arguments);
});
}(window, rJS, jIO));
\ No newline at end of file
......@@ -177,6 +177,7 @@
});
})
.push(undefined, function (error) {
// XXX-catchall
var message_text,
code = 0;
if (error instanceof jIO.util.jIOError) {
......@@ -185,6 +186,7 @@
} else if (error instanceof TypeError || error.message) {
message_text = error.message;
} else {
// XXX-catchall could be solved by putting here only throw error;
code = error.target.status;
message_text = error.target.responseType === "text" ?
error.target.statusText : "";
......
......@@ -67,6 +67,7 @@
return gadget.jio_repair();
})
.push(undefined, function (error) {
// XXX-catchall
// should include error message in error
has_error = true;
console.error(error);
......@@ -121,6 +122,7 @@
return testOnline(parser.origin);
})
.push(undefined, function () {
// XXX-catchall
return {status: "ERROR"};
})
.push(function (online_result) {
......
......@@ -49,6 +49,7 @@
);
})
.push(undefined, function (error) {
// XXX-catchall
gadget.state.data_dict.data = {};
return gadget.notifySubmitted({
message: "Warning: Failed to download graph data file '" +
......
......@@ -212,6 +212,7 @@
return storage.removeAttachment(id, name);
})
.push(undefined, function (error) {
// XXX-catchall: This shall be another branch of promise above to not be catch-all like it's now
if ((error instanceof jIO.util.jIOError) &&
(error.status_code === 404)) {
return undefined;
......@@ -272,7 +273,7 @@
(error.status_code === 404)) {
return undefined;
}
console.error(error);
console.error(error); // XXX-catchall: this shall be throw error
})
.push(function (attachment) {
if (attachment) {
......@@ -366,6 +367,7 @@
};
return sub_storage.allDocs({include_docs: true})
.push(undefined, function (error) {
// XXX-catchall
//throw error;
console.error(error);
return undefined;
......@@ -469,7 +471,7 @@
return {data: {total_rows: 0}};
}
//throw error;
console.error(error);
console.error(error); // XXX-catchall throw error
return {data: {total_rows: 0}};
})
.push(function (opml_result) {
......@@ -792,7 +794,7 @@
);
})
.push(undefined, function (error) {
console.error(error);
console.error(error); // XXX-catchall: throw error
});
}
for (j = 0; j < attachment_document_list.length; j += 1) {
......
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