<commit_before>/**
 * Automatically reconnects to Steam network if:
 *
 * * we get disconnected
 * * we receive `ServiceUnavailable` or `TryAnotherCM` after logging in
 *
 * Any other case is ignored.
 * @example
 * // use default reconnect timeout of 5000ms (5 seconds)
 * bot.use(vapor.plugins.reconnectOnError);
 *
 * // supply our own timeout value of 3000ms (3 seconds)
 * bot.use(vapor.plugins.reconnectOnError, 3000);
 * @param {Object} VaporAPI Instance of the API class.
 * @module
 */
exports.name = 'reconnect-on-error';

exports.plugin = function(VaporAPI) {
    var DEFAULT_TIMEOUT = 5000;

    var timeout = VaporAPI.data || DEFAULT_TIMEOUT;
    var Steam = VaporAPI.getSteam();

    // Handle 'error' event
    VaporAPI.registerHandler({
            emitter: 'vapor',
            event: 'error'
        },
        function(error) {
            switch (error.cause) {
                case 'disconnected':
                    setTimeout(VaporAPI.connect, timeout);
                    break;

                case 'loginError':
                    if(error.response.eresult === Steam.EResult.ServiceUnavailable ||
                    error.response.eresult === Steam.EResult.TryAnotherCM) {
                        setTimeout(VaporAPI.connect, timeout);
                    }

                    break;
                default:
                    throw new Error('Unknown error cause: %s.', error.cause);
            }
        }
    );
};<commit_msg>add log messages to reconnectOnError plugin<commit_after>/**
 * Automatically reconnects to Steam network if:
 *
 * * we get disconnected
 * * we receive `ServiceUnavailable` or `TryAnotherCM` after logging in
 *
 * Any other case is ignored.
 * @example
 * // use default reconnect timeout of 5000ms (5 seconds)
 * bot.use(vapor.plugins.reconnectOnError);
 *
 * // supply our own timeout value of 3000ms (3 seconds)
 * bot.use(vapor.plugins.reconnectOnError, 3000);
 * @param {Object} VaporAPI Instance of the API class.
 * @module
 */
exports.name = 'reconnect-on-error';

exports.plugin = function(VaporAPI) {
    var DEFAULT_TIMEOUT = 5000;

    var timeout = VaporAPI.data || DEFAULT_TIMEOUT;
    var Steam = VaporAPI.getSteam();
    var log = VaporAPI.getLogger();

    // Handle 'error' event
    VaporAPI.registerHandler({
            emitter: 'vapor',
            event: 'error'
        },
        function(error) {
            switch (error.cause) {
                case 'disconnected':
                    log.info('Reconnecting in %dms.', timeout);
                    setTimeout(VaporAPI.connect, timeout);
                    break;

                case 'loginError':
                    if(error.response.eresult === Steam.EResult.ServiceUnavailable ||
                    error.response.eresult === Steam.EResult.TryAnotherCM) {
                        log.info('Reconnecting in %dms.', timeout);
                        setTimeout(VaporAPI.connect, timeout);
                    }

                    break;
                default:
                    throw new Error('Unknown error cause: %s.', error.cause);
            }
        }
    );
};
{'fraction_non_alphanumeric': 0.1090153452685422, 'fraction_numerical': 0.011508951406649617, 'mean_word_length': 1.9106976744186046, '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': '7129160', 'n_tokens_mistral': 901, 'n_tokens_neox': 834, 'n_words': 216}