From fa47ad120172b9cb0c6dfe200159588300fcb175 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 17 Nov 2014 14:55:36 -0400 Subject: [PATCH] Implement handy logErrorOrContinue --- lib/error/error.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/error/error.coffee diff --git a/lib/error/error.coffee b/lib/error/error.coffee new file mode 100644 index 00000000..3b59f4fe --- /dev/null +++ b/lib/error/error.coffee @@ -0,0 +1,14 @@ +exports.logErrorOrContinue = (func, context) -> + return -> + try + func.apply(context, arguments) + catch error + + # TODO: There should be a log module that takes + # care of logging, and this should delegate to it + console.error("Error: #{error.message}") + + # TODO: Allow errors to save an error code + # and use that here if it exists + process.exit(1) +