Skip to content

Commit 762494e

Browse files
authored
Better error handling (ITISFoundation#2368)
* Allow wrapped text wrapping * FRIENDLY_HTTP_STATUS * handle unresponsive backend * Added "Please, try again later" to 404 and 503 error messages
1 parent c027086 commit 762494e

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

services/web/client/source/class/osparc/Error.js

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,52 @@ qx.Class.define("osparc.Error", {
5151
}
5252
},
5353

54+
statics: {
55+
FRIENDLY_HTTP_STATUS: {
56+
"200": "OK",
57+
"201": "Created",
58+
"202": "Accepted",
59+
"203": "Non-Authoritative Information",
60+
"204": "No Content",
61+
"205": "Reset Content",
62+
"206": "Partial Content",
63+
"300": "Multiple Choices",
64+
"301": "Moved Permanently",
65+
"302": "Found",
66+
"303": "See Other",
67+
"304": "Not Modified",
68+
"305": "Use Proxy",
69+
"306": "Unused",
70+
"307": "Temporary Redirect",
71+
"400": "Bad Request",
72+
"401": "Unauthorized",
73+
"402": "Payment Required",
74+
"403": "Forbidden",
75+
"404": "Not Found",
76+
"405": "Method Not Allowed",
77+
"406": "Not Acceptable",
78+
"407": "Proxy Authentication Required",
79+
"408": "Request Timeout",
80+
"409": "Conflict",
81+
"410": "Gone",
82+
"411": "Length Required",
83+
"412": "Precondition Required",
84+
"413": "Request Entry Too Large",
85+
"414": "Request-URI Too Long",
86+
"415": "Unsupported Media Type",
87+
"416": "Requested Range Not Satisfiable",
88+
"417": "Expectation Failed",
89+
"418": "I'm a teapot",
90+
"429": "Too Many Requests",
91+
"500": "Internal Server Error",
92+
"501": "Not Implemented",
93+
"502": "Bad Gateway",
94+
"503": "Service Unavailable",
95+
"504": "Gateway Timeout",
96+
"505": "HTTP Version Not Supported"
97+
}
98+
},
99+
54100
members: {
55101
__status: null,
56102
__messages: null,
@@ -76,21 +122,23 @@ qx.Class.define("osparc.Error", {
76122
control = new qx.ui.basic.Label().set({
77123
font: "text-18",
78124
alignX: "center",
79-
width: 200
125+
rich : true,
126+
width: 300
80127
});
81128
break;
82129
}
83130
case "messages-layout": {
84131
control = new qx.ui.container.Composite(new qx.ui.layout.VBox(10)).set({
85132
alignX: "center",
86-
maxWidth: 200
133+
maxWidth: 300
87134
});
88135
break;
89136
}
90137
case "message": {
91138
control = new qx.ui.basic.Label().set({
92139
font: "text-16",
93-
maxWidth: 200
140+
rich : true,
141+
width: 300
94142
});
95143
break;
96144
}
@@ -128,7 +176,9 @@ qx.Class.define("osparc.Error", {
128176
},
129177

130178
_applyCode: function(status) {
131-
this.__status.setValue("Error: " + status);
179+
if (status in this.self().FRIENDLY_HTTP_STATUS) {
180+
this.__status.setValue("Error: " + this.self().FRIENDLY_HTTP_STATUS[status]);
181+
}
132182
},
133183

134184
_applyMessages: function(messages) {

services/web/client/source/class/osparc/data/Resources.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,15 @@ qx.Class.define("osparc.data.Resources", {
631631
message = logs[0].message;
632632
}
633633
status = e.getData().error.status;
634+
} else {
635+
const req = e.getRequest();
636+
message = req.getResponse();
637+
status = req.getStatus();
634638
}
635639
res.dispose();
640+
if ([404, 503].includes(status)) {
641+
message += "<br>Please, try again later";
642+
}
636643
const err = Error(message ? message : `Error while trying to fetch ${endpoint} ${resource}`);
637644
if (status) {
638645
err.status = status;

0 commit comments

Comments
 (0)