/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
- #!/usr/bin/env node
- (function (undefined) {
- "use strict";
- process.title = "capture-notify-gmti";
- process.on("uncaughtException", function (err) {
- console.log("uncaughtException");
- console.log(JSON.stringify(err));
-
- var fs = require("fs");
- fs.writeFile("/tmp/" + process.title + "-" + process.pid + ".log", JSON.stringify(err), function (err) {
- if (err) {
- console.log("could not log");
- console.log(JSON.stringify(err));
- }
- process.exit(-117);
- });
- });
- throw new Error("craptacular exception");
- });