diff options
author | isaacs <i@izs.me> | 2010-05-08 22:38:21 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-05-08 22:38:21 +0400 |
commit | a1e0250aa32f749e650721f3c85783881e2a0c60 (patch) | |
tree | 638f03f59e455870031b692805bcfb705f860892 /lib | |
parent | 3421bbe3cba796b5d840f26975470e796f92ffbf (diff) |
Add a "log error or continue" function to wrap a callback when no other action is required.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/log.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils/log.js b/lib/utils/log.js index 522c5cf3c..143071e99 100644 --- a/lib/utils/log.js +++ b/lib/utils/log.js @@ -11,3 +11,11 @@ function log (msg, pref, cb) { cb && cb() } +log.er = function (cb, msg) { + if (!msg) throw new Error( + "Why bother logging it if you're not going to print a message?") + return function (er) { + if (er) log(msg, "fail") + cb.apply(this, arguments) + } +} |