<commit_before>function getError(config) {
  return function error(err, req, res, next) {

    if(!err) {
      err = new HTTPError('Not Found', 404, '/')
    }

    let d = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')

    if(!config.quiet)
      if(config.dev)
        console.error(d, err.stack);
      else
        console.error(d, err.code + ' - ' + err.message)

    return res.format({
      'text/plain': function() {
        return res.status(err.code).send(err.message).end()
      },
      'text/html': function() {
        req.flash('error', err.message)
         
        return res.redirect(err.redirect)
      },
      'application/json': function() {
        return res.status(err.code).json(err).end()
      },
      'default': function() {
        return res.status(406).send('Not acceptable')
      }
    })
  }
}

export {getError}<commit_msg>fix(): No text/plain format, 500 if no errors 404 are handled by expresso (http://expressjs.com/starter/faq.html#how-do-you-handle-404s)<commit_after>function getError(config) {
  return function error(err, req, res, next) {

    if(!err) {
      err = new HTTPError('No errors - please report', 500, '/')
    }

    let d = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')

    if(!config.quiet)
      if(config.dev)
        console.error(d, err.stack);
      else
        console.error(d, err.code + ' - ' + err.message)

    return res.format({
      'text/html': function() {
        req.flash('error', err.message)
         
        return res.redirect(err.redirect)
      },
      'application/json': function() {
        return res.status(err.code).json(err).end()
      },
      'default': function() {
        return res.status(406).send('Not acceptable')
      }
    })
  }
}

export {getError}
{'fraction_non_alphanumeric': 0.17787659811006115, 'fraction_numerical': 0.011673151750972763, 'mean_word_length': 2.266787658802178, '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': '4292289', 'n_tokens_mistral': 602, 'n_tokens_neox': 576, 'n_words': 110}