<commit_before>
module.exports = errorHandler

var cbCalled = false
  , log = require("./log")
  , npm = require("../../npm")
  , rm = require("./rm-rf")
  , constants
  , itWorked = false

try { constants = require("constants") }
catch (ex) { constants = process }

process.on("exit", function (code) {
  if (code) itWorked = false
  log.win(itWorked ? "ok" : "not ok")
  itWorked = false // ready for next exit
})

function errorHandler (er) {
  if (cbCalled) throw new Error("Callback called more than once.")
  cbCalled = true
  if (!er) return exit(0)
  log.error(er)
  if (!(er instanceof Error)) return exit(1)
  if (!er.errno) {
    var m = er.message.match(/^(?:Error: )?(E[A-Z]+)/)
    if (m) {
      m = m[1]
      if (!constants[m] && !npm[m]) constants[m] = {}
      er.errno = npm[m] || constants[m]
    }
  }
  switch (er.errno) {
  case constants.ECONNREFUSED:
    log.error(["If you are using Cygwin, please set up your /etc/resolv.conf"
              ,"See step 3 in this wiki page:"
              ,"    http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29"
              ,"If you are not using Cygwin, please report this"
              ,"at <http://github.com/isaacs/npm/issues>"
              ,"or email it to <<EMAIL>>"
              ].join("\n"))
    break
  case constants.EACCES:
    log.error(["There appear to be some permission problems"
              ,"See the section on 'Permission Errors' at"
              ,"  http://github.com/isaacs/npm#readme"
              ,"This will get better in the future, I promise."
              ].join("\n"))
    break
  case npm.ELIFECYCLE:<commit_msg>It's step 4 now.<commit_after>
module.exports = errorHandler

var cbCalled = false
  , log = require("./log")
  , npm = require("../../npm")
  , rm = require("./rm-rf")
  , constants
  , itWorked = false

try { constants = require("constants") }
catch (ex) { constants = process }

process.on("exit", function (code) {
  if (code) itWorked = false
  log.win(itWorked ? "ok" : "not ok")
  itWorked = false // ready for next exit
})

function errorHandler (er) {
  if (cbCalled) throw new Error("Callback called more than once.")
  cbCalled = true
  if (!er) return exit(0)
  log.error(er)
  if (!(er instanceof Error)) return exit(1)
  if (!er.errno) {
    var m = er.message.match(/^(?:Error: )?(E[A-Z]+)/)
    if (m) {
      m = m[1]
      if (!constants[m] && !npm[m]) constants[m] = {}
      er.errno = npm[m] || constants[m]
    }
  }
  switch (er.errno) {
  case constants.ECONNREFUSED:
    log.error(["If you are using Cygwin, please set up your /etc/resolv.conf"
              ,"See step 4 in this wiki page:"
              ,"    http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29"
              ,"If you are not using Cygwin, please report this"
              ,"at <http://github.com/isaacs/npm/issues>"
              ,"or email it to <<EMAIL>>"
              ].join("\n"))
    break
  case constants.EACCES:
    log.error(["There appear to be some permission problems"
              ,"See the section on 'Permission Errors' at"
              ,"  http://github.com/isaacs/npm#readme"
              ,"This will get better in the future, I promise."
              ].join("\n"))
    break
  case npm.ELIFECYCLE:
{'fraction_non_alphanumeric': 0.16080709263222256, 'fraction_numerical': 0.005197187404463467, 'mean_word_length': 2.3627954779033917, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6058524', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1088, 'n_words': 304}