1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

[file view] added 'catch' for requests

* added 'getErrorMsg' to utils.js
This commit is contained in:
llj
2019-07-04 16:20:13 +08:00
parent 15e715c346
commit 16015ee8e7
2 changed files with 31 additions and 0 deletions

View File

@@ -734,6 +734,23 @@ export const Utils = {
return items;
},
/*
* only used in the 'catch' part of a seafileAPI request
*/
getErrorMsg: function(error) {
let errorMsg = '';
if (error.response) {
if (error.response.data && error.response.data['error_msg']) {
errorMsg = error.response.data['error_msg'];
} else {
errorMsg = gettext('Error');
}
} else {
errorMsg = gettext('Please check the network.');
}
return errorMsg;
},
changeMarkdownNodes: function(nodes, fn) {
nodes.map((item) => {
fn(item);