<commit_before>var Supersede = require('supersede')
var assert = require('assert')
var slice = [].slice
var typeIdentifiers = {}

function rescue (error) {
    var vargs = slice.call(arguments)
    return function (error) {
        if (!(error.path && error.typeIdentifier && typeIdentifiers[error.path] == error.typeIdentifier)) {
            throw error
        }
        var cases = [], when, arg
        var map = new Supersede, state = 'begin'
        while (arg = vargs.shift()) {
            if (Array.isArray(arg)) {
                vargs.unshift.apply(vargs, arg)
            } else {
                switch (state) {
                case 'begin':
                    assert.ok(typeof arg == 'string')
                    when = { path: ('.' + arg).split('.') }
                    state = 'when'
                    break
                case 'when':
                    if (arg instanceof RegExp) {
                        when.regex = arg
                        state = 'regex'
                        break
                    } else {
                        when.regex = /^/
                    }
                case 'regex':
                    assert.ok(typeof arg == 'function')
                    when.f = arg
                    cases.push(when)
                    state = 'begin'
                    break
                }
            }
        }
        for (var i = 0, I = cases.length; i < I; i++) {
            when = cases[i]
            map.set(when.path, when)
        }
        var path = ('.' + error.path + '.' + error.message).split('.')
        var when = map.get(path)
        if (when == null || !when.regex.test(error.errno || error.message)) {
            throw error
        }
        when.f(error)
    }
}

exports.rescue = rescue
exports.createInterrupter = function (path) {
    var typeIdentifier = typeIdentifiers[path] = {}
    function interrupt (error) {
        // see: http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript
        var vargs = slice.call(arguments, 1)
        error.path = path
        error.typeIdentifier = typeIdentifier
        vargs.forEach(function (values) {
            for (var key in values) {
                error[key] = values[key]
            }
        })
        return error
    }
    interrupt.rescue = rescue
    return interrupt
}
<commit_msg>Return result of catch function.<commit_after>var Supersede = require('supersede')
var assert = require('assert')
var slice = [].slice
var typeIdentifiers = {}

function rescue (error) {
    var vargs = slice.call(arguments)
    return function (error) {
        if (!(error.path && error.typeIdentifier && typeIdentifiers[error.path] == error.typeIdentifier)) {
            throw error
        }
        var cases = [], when, arg
        var map = new Supersede, state = 'begin'
        while (arg = vargs.shift()) {
            if (Array.isArray(arg)) {
                vargs.unshift.apply(vargs, arg)
            } else {
                switch (state) {
                case 'begin':
                    assert.ok(typeof arg == 'string')
                    when = { path: ('.' + arg).split('.') }
                    state = 'when'
                    break
                case 'when':
                    if (arg instanceof RegExp) {
                        when.regex = arg
                        state = 'regex'
                        break
                    } else {
                        when.regex = /^/
                    }
                case 'regex':
                    assert.ok(typeof arg == 'function')
                    when.f = arg
                    cases.push(when)
                    state = 'begin'
                    break
                }
            }
        }
        for (var i = 0, I = cases.length; i < I; i++) {
            when = cases[i]
            map.set(when.path, when)
        }
        var path = ('.' + error.path + '.' + error.message).split('.')
        var when = map.get(path)
        if (when == null || !when.regex.test(error.errno || error.message)) {
            throw error
        }
        return when.f(error)
    }
}

exports.rescue = rescue
exports.createInterrupter = function (path) {
    var typeIdentifier = typeIdentifiers[path] = {}
    function interrupt (error) {
        // see: http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript
        var vargs = slice.call(arguments, 1)
        error.path = path
        error.typeIdentifier = typeIdentifier
        vargs.forEach(function (values) {
            for (var key in values) {
                error[key] = values[key]
            }
        })
        return error
    }
    interrupt.rescue = rescue
    return interrupt
}

{'fraction_non_alphanumeric': 0.11827731092436974, 'fraction_numerical': 0.003781512605042017, 'mean_word_length': 1.28564570331253, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5233077', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1241, 'n_words': 297}