Permalink
Browse files

The call of callback function was issued out of try-catch.

  • Loading branch information...
1 parent 081f915 commit 2465b0d9ac2c35fbf4686da0d4069c8c0822f66c @tuchida committed Dec 30, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/jst.js
View
@@ -109,7 +109,8 @@ var renderFile = exports.renderFile = function(filename, args, fn) {
args = {};
}
- var fk = hash.md5sum(filename);
+ var fk = hash.md5sum(filename),
+ res;
fs.stat(filename, function(err, stats) {
if (err)
@@ -126,13 +127,15 @@ var renderFile = exports.renderFile = function(filename, args, fn) {
_files[fk].ctx = ctx;
try {
- fn(null, render(ctx, args));
+ res = render(ctx, args);
} catch(e) { fn(e); }
+ fn(null, res);
});
} else {
try {
- fn(null, render(_files[fk].ctx, args));
+ res = render(_files[fk].ctx, args);
} catch(e) { fn(e); }
+ fn(null, res);
}
});
}

0 comments on commit 2465b0d

Please sign in to comment.