<commit_before>(function (require, module) {
  'use strict';

  var MongooseValidationError =
    require('mongoose/lib/error/validation');
  var InvalidQueryParams =
    require('../include/invalidQueryParams.js');

  module.exports = function (err, req, res, next) {
    // Client Errors (400)

    if (err instanceof MongooseValidationError) {
      return res.status(400)
        .send({
          type: 'ValidationError',
          detail: err.toString()
        });
    }

    if (err instanceof InvalidQueryParams) {
      return res.status(400)
        .send({
          type: 'InvalidQueryParams',
          detail: err.toString(),
          params: err.params
        });
    }
  };
})(require, module);
<commit_msg>Fixed a serious bug that was swollowing uncaught exceptions and causing the server to hang.<commit_after>(function (require, module) {
  'use strict';

  var MongooseValidationError =
    require('mongoose/lib/error/validation');
  var InvalidQueryParams =
    require('../include/invalidQueryParams.js');
  var colors = require('colors');

  module.exports = function (err, req, res, next) {
    // Client Errors (400)

    if (err instanceof MongooseValidationError) {
      //console.log('Invalid Client Request:  '.red,
      //  '[MongooseValidationError]'.yellow,
       // err.toString());
      return res.status(400)
        .send({
          type: 'ValidationError',
          detail: err.toString()
        });
    }

    if (err instanceof InvalidQueryParams) {
      //console.log('Invalid Client Request:  '.red,
      //  '[InvalidQueryParams]'.yellow,
      //  err.toString());
      return res.status(400)
        .send({
          type: 'InvalidQueryParams',
          detail: err.toString(),
          params: err.params
        });
    }

    // Pass her right along through
    next(err);
  };
})(require, module);

{'fraction_non_alphanumeric': 0.13526570048309178, 'fraction_numerical': 0.00966183574879227, 'mean_word_length': 2.426470588235294, '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': '2871499', 'n_tokens_mistral': 539, 'n_tokens_neox': 516, 'n_words': 127}