/tests/catch-uncaught-exception-test.js

http://github.com/coolaj86/node-examples-js · JavaScript · 21 lines · 18 code · 3 blank · 0 comment · 1 complexity · d43eca11cb7f24f9a476adf7eb4b943b MD5 · raw file

  1. #!/usr/bin/env node
  2. (function (undefined) {
  3. "use strict";
  4. process.title = "capture-notify-gmti";
  5. process.on("uncaughtException", function (err) {
  6. console.log("uncaughtException");
  7. console.log(JSON.stringify(err));
  8. var fs = require("fs");
  9. fs.writeFile("/tmp/" + process.title + "-" + process.pid + ".log", JSON.stringify(err), function (err) {
  10. if (err) {
  11. console.log("could not log");
  12. console.log(JSON.stringify(err));
  13. }
  14. process.exit(-117);
  15. });
  16. });
  17. throw new Error("craptacular exception");
  18. });