<commit_before>"use strict";

var delegate = require('delegates');

var Deferred = require('./deferred');

var proto = module.exports = {

    /**
     * Throw an error with `msg` and optional `status`
     * defaulting to 500. Note that these are user-level
     * errors, and the message may be exposed to the client.
     *
     *    this.throw(403)
     *    this.throw('name required', 400)
     *    this.throw(400, 'name required')
     *    this.throw('something exploded')
     *    this.throw(new Error('invalid'), 400);
     *    this.throw(400, new Error('invalid'));
     *
     * @param {String|Number|Error} msg err, msg or status
     * @param {String|Number|Error} status err, msg or status
     * @api public
     */

    throw: function (msg, status) {
        if ('number' == typeof msg) {
            var tmp = msg;
            msg = status;// || http.STATUS_CODES[tmp];
            status = tmp;
        }

        var err = msg instanceof Error ? msg : new Error(msg);
        err.status = status || err.status || 500;
        err.expose = err.status < 500;
        throw err;
    },


    defer: function (canceler) {
        if (this.future) throw new Error('This context has been deferred');
        var d = new Deferred();
        this.future = d.future;
        d.canceler(canceler);
        return d;
    }
}
;

delegate(proto, 'request')
    .getter('uri')
    .getter('payload');<commit_msg>refactor<commit_after>"use strict";

var delegate = require('delegates');

var Deferred = require('./deferred');

var proto = module.exports = {

    /**
     * Throw an error with `msg` and optional `status`
     * defaulting to 500. Note that these are user-level
     * errors, and the message may be exposed to the client.
     *
     *    this.throw(403)
     *    this.throw('name required', 400)
     *    this.throw(400, 'name required')
     *    this.throw('something exploded')
     *    this.throw(new Error('invalid'), 400);
     *    this.throw(400, new Error('invalid'));
     *
     * @param {String|Number|Error} msg err, msg or status
     * @param {String|Number|Error} status err, msg or status
     * @api public
     */

    throw: function (msg, status) {
        if ('number' == typeof msg) {
            var tmp = msg;
            msg = status;// || http.STATUS_CODES[tmp];
            status = tmp;
        }

        var err = msg instanceof Error ? msg : new Error(msg);
        err.status = status || err.status || 500;
        err.expose = err.status < 500;
        throw err;
    },


    defer: function (canceler) {
        if (this.future) throw new Error('This context has been deferred');
        var d = new Deferred();
        this.future = d.future;
        if (canceler) d.canceler(canceler);
        return d;
    }
}
;

delegate(proto, 'request')
    .getter('uri')
    .getter('payload');
{'fraction_non_alphanumeric': 0.13739922888187872, 'fraction_numerical': 0.016824395373291272, 'mean_word_length': 2.1605758582502768, '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': '1146982', 'n_tokens_mistral': 910, 'n_tokens_neox': 855, 'n_words': 253}