mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(util) rm tryLog, logError
This commit is contained in:
parent
28da3c2e76
commit
d65a349c70
2 changed files with 4 additions and 42 deletions
|
|
@ -46,14 +46,12 @@
|
|||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
error = Util.exec.tryLog(function() {
|
||||
error = Util.exec.try(function() {
|
||||
diffResult = diff.applyPatch(data, patch);
|
||||
});
|
||||
|
||||
if (error || !diffResult)
|
||||
callback({
|
||||
message: 'Patch fail'
|
||||
});
|
||||
if (error)
|
||||
callback(error);
|
||||
else
|
||||
fs.writeFile(name, diffResult, callback);
|
||||
}
|
||||
|
|
|
|||
38
lib/util.js
38
lib/util.js
|
|
@ -190,7 +190,7 @@
|
|||
this.stringify = function(obj) {
|
||||
var str;
|
||||
|
||||
Util.exec.tryLog(function() {
|
||||
Util.exec.try(function() {
|
||||
str = JSON.stringify(obj, null, 4);
|
||||
});
|
||||
|
||||
|
|
@ -255,25 +255,6 @@
|
|||
return args.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* function log pArg if it's not empty
|
||||
* @param pArg
|
||||
*/
|
||||
this.logError = function(pArg) {
|
||||
var lConsole = Scope.console,
|
||||
lDate = '[' + Util.getDate() + '] ';
|
||||
|
||||
if (lConsole && pArg) {
|
||||
var lMsg = pArg.message;
|
||||
if (lMsg)
|
||||
lDate += pArg.message + ' ';
|
||||
|
||||
lConsole.error(lDate, pArg);
|
||||
}
|
||||
|
||||
return pArg;
|
||||
};
|
||||
|
||||
/**
|
||||
* function remove substring from string
|
||||
* @param str
|
||||
|
|
@ -690,23 +671,6 @@
|
|||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* function gets file extension
|
||||
* @param pFileName
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue