<commit_before>var crypto = require('crypto'),
    utils = require('../utils'),
    Client = require('../raven').Client;

module.exports = function raven(options) {
    var client = new Client(options);
    return function(err, req, res, next) {
        var kwargs = {
            'sentry.interfaces.Http': {
                method: req.method,
                data: {META: {
                    headers: req.headers,
                }},
                url: (function build_absolute_url(req) {
                    var protocol = req.socket.encrypted ? 'https' : 'http',
                        host = req.headers.host || '<no host>';
                    return protocol+'://'+host+req.url;
                }(req))
            }
        };
        //console.log(err.stack);
        client.create_from_exception(err, kwargs, function(result) {
            res.sentry = {id: 1};
            res.statusCode = 500;
            res.end(client.get_ident(result));
        });
        
    };
};<commit_msg>Don't exit out in Raven middleware. Pass along the sentry object.<commit_after>var crypto = require('crypto'),
    utils = require('../utils'),
    Client = require('../raven').Client;

module.exports = function raven(options) {
    var client = (options instanceof Client) ? options : new Client(options);
    return function(err, req, res, next) {
        var kwargs = {
            'sentry.interfaces.Http': {
                method: req.method,
                data: {META: {
                    headers: req.headers,
                }},
                url: (function build_absolute_url(req) {
                    var protocol = req.socket.encrypted ? 'https' : 'http',
                        host = req.headers.host || '<no host>';
                    return protocol+'://'+host+req.url;
                }(req))
            }
        };
        client.createFromError(err, kwargs, function(result) {
            result.ident = client.getIdent(result);
            res.sentry = result;
            next(err, req, res);
        });
    };
};
{'fraction_non_alphanumeric': 0.13880742913000976, 'fraction_numerical': 0.0019550342130987292, 'mean_word_length': 1.5683814303638646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1340514', 'n_tokens_mistral': 565, 'n_tokens_neox': 540, 'n_words': 120}