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