mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-22 15:39:34 +00:00
feature(util) tryCatch{Log} -> exec.try{Log}
This commit is contained in:
parent
47d475fdb5
commit
1b000bc063
6 changed files with 39 additions and 39 deletions
|
|
@ -347,7 +347,7 @@ var CloudCmd, Util, DOM;
|
|||
DOM.scrollByPages(panel, -1);
|
||||
|
||||
var tryCatch = function(pCurrentFile) {
|
||||
Util.tryCatch(function() {
|
||||
Util.exec.try(function() {
|
||||
return pCurrentFile
|
||||
.previousSibling
|
||||
.previousSibling
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
* if watched files would be more then system limit
|
||||
*/
|
||||
var lWatch_f = function() {
|
||||
Util.tryCatch(function() {
|
||||
Util.exec.try(function() {
|
||||
fs_watch(pFileName, on_fs_watch(pFileName));
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@
|
|||
|
||||
сommand = args.shift();
|
||||
|
||||
error = Util.tryCatchLog(function() {
|
||||
error = Util.exec.tryLog(function() {
|
||||
cmd = spawn(сommand, args, options);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@
|
|||
*/
|
||||
function mrequire(src) {
|
||||
var module, msg,
|
||||
error = Util.tryCatch(function() {
|
||||
error = Util.exec.try(function() {
|
||||
module = require(src);
|
||||
});
|
||||
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
function quietrequire(src) {
|
||||
var module;
|
||||
|
||||
Util.tryCatch(function() {
|
||||
Util.exec.try(function() {
|
||||
module = require(src);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
if (error)
|
||||
func(error);
|
||||
else {
|
||||
error = Util.tryCatchLog(function() {
|
||||
error = Util.exec.tryLog(function() {
|
||||
diffResult = diff.applyPatch(data, patch);
|
||||
});
|
||||
|
||||
|
|
|
|||
66
lib/util.js
66
lib/util.js
|
|
@ -204,7 +204,7 @@
|
|||
this.parseJSON = function(str) {
|
||||
var obj;
|
||||
|
||||
Util.tryCatch(function() {
|
||||
Util.exec.try(function() {
|
||||
obj = JSON.parse(str);
|
||||
});
|
||||
|
||||
|
|
@ -217,7 +217,7 @@
|
|||
this.stringifyJSON = function(obj) {
|
||||
var str;
|
||||
|
||||
Util.tryCatchLog(function() {
|
||||
Util.exec.tryLog(function() {
|
||||
str = JSON.stringify(obj, null, 4);
|
||||
});
|
||||
|
||||
|
|
@ -669,37 +669,6 @@
|
|||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* function execute param function in
|
||||
* try...catch block
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
this.tryCatch = function(callback) {
|
||||
var ret;
|
||||
try {
|
||||
ret = callback();
|
||||
} catch(error) {
|
||||
ret = error;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* function execute param function in
|
||||
* try...catch block and log result
|
||||
*
|
||||
* @param pTryFunc
|
||||
*/
|
||||
this.tryCatchLog = function(pTryFunc) {
|
||||
var ret;
|
||||
|
||||
ret = Util.tryCatch(pTryFunc);
|
||||
|
||||
return Util.logError(ret);
|
||||
};
|
||||
|
||||
this.exec = new ExecProto();
|
||||
|
||||
function ExecProto() {
|
||||
|
|
@ -823,6 +792,37 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* function execute param function in
|
||||
* try...catch block
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
exec.try = function(callback) {
|
||||
var ret;
|
||||
try {
|
||||
ret = callback();
|
||||
} catch(error) {
|
||||
ret = error;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* function execute param function in
|
||||
* try...catch block and log result
|
||||
*
|
||||
* @param tryFunc
|
||||
*/
|
||||
exec.tryLog = function(tryFunc) {
|
||||
var ret;
|
||||
|
||||
ret = this.try(tryFunc);
|
||||
|
||||
return Util.logError(ret);
|
||||
};
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue