Permalink
Browse files

Added warning on done fail

Fixes #37

Closes gh-67.
  • Loading branch information...
1 parent a928625 commit 54bbe86078b9d869464c2f60dc300a7d6554a2ae @jmeas jmeas committed with tkellen Feb 26, 2014
Showing with 9 additions and 1 deletion.
  1. +9 −1 tasks/requirejs.js
View
@@ -33,7 +33,15 @@ module.exports = function(grunt) {
done();
}
});
+ // The following catches errors in the user-defined `done` function and outputs them.
+ var tryCatch = function(fn, done, output) {
+ try {
+ fn(done, output);
+ } catch(e) {
+ grunt.fail.warn('There was an error while processing your done function: "' + e + '"');
+ }
+ };
- requirejs.optimize(options, options.done.bind(null, done));
+ requirejs.optimize(options, tryCatch.bind(null, options.done, done));
});
};

0 comments on commit 54bbe86

Please sign in to comment.