<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 () { if (!itWorked) log.win("not ok") })

function errorHandler (er) {
  if (cbCalled) throw new Error("Callback called more than once.")
  cbCalled = true
  if (!er) {
    itWorked = true
    log.win("ok")
    return exit()
  }
  log.error(er)
  if (!(er instanceof Error)) return exit(1)
  switch (er.errno) {
  case constants.ECONNREFUSED:
    log.error(["If you are using Cygwin, please set up your /etc/resolv.conf"<commit_msg>If the errno is missing, but discoverable, then add it.<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 () { if (!itWorked) log.win("not ok") })

function errorHandler (er) {
  if (cbCalled) throw new Error("Callback called more than once.")
  cbCalled = true
  if (!er) {
    itWorked = true
    log.win("ok")
    return exit()
  }
  log.error(er)
  if (!(er instanceof Error)) return exit(1)
  if (!er.errno) {
    var m = er.message.match(/^E[A-Z]+/)
    if (m) {
      m = m[0]
      if (constants[m]) er.errno = constants[m]
    }
  }
  switch (er.errno) {
  case constants.ECONNREFUSED:
    log.error(["If you are using Cygwin, please set up your /etc/resolv.conf"
{'fraction_non_alphanumeric': 0.16443361753958588, 'fraction_numerical': 0.0018270401948842874, 'mean_word_length': 3.1700507614213196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3713312', 'n_tokens_mistral': 567, 'n_tokens_neox': 572, 'n_words': 161}