PageRenderTime 55ms CodeModel.GetById 35ms app.highlight 3ms RepoModel.GetById 14ms app.codeStats 0ms

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