<commit_before>var assert = require("assert");
var path = require("path");
var fs = require("fs");
var Q = require("q");
var createHash = require("crypto").createHash;
var mkdirp = require("mkdirp");
var log = require("util").log;
var Ap = Array.prototype;
var slice = Ap.slice;
var join = Ap.join;

function makePromise(callback, context) {
    var deferred = Q.defer();

    process.nextTick(function() {
        callback.call(context || null, function(err, result) {
            if (err) {
                deferred.reject(err);
            } else {
                deferred.resolve(result);
            }
        });<commit_msg>Handle exceptions thrown by util.makePromise callback.<commit_after>var assert = require("assert");
var path = require("path");
var fs = require("fs");
var Q = require("q");
var createHash = require("crypto").createHash;
var mkdirp = require("mkdirp");
var log = require("util").log;
var Ap = Array.prototype;
var slice = Ap.slice;
var join = Ap.join;

function makePromise(callback, context) {
    var deferred = Q.defer();

    function finish(err, result) {
        if (err) {
            deferred.reject(err);
        } else {
            deferred.resolve(result);
        }
    }

    process.nextTick(function() {
        try {
            callback.call(context || null, finish);
        } catch (err) {
            finish(err);
        }
{'fraction_non_alphanumeric': 0.14763636363636365, 'fraction_numerical': 0.0, 'mean_word_length': 2.649867374005305, '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': '5340750', 'n_tokens_mistral': 402, 'n_tokens_neox': 392, 'n_words': 103}