<commit_before>define([
    '/common/realtime-input.js'
], function () {
    var ChainPad = window.ChainPad;
    var JsonOT = {};

    var validate = JsonOT.validate = function (text, toTransform, transformBy) {
        var resultOp = ChainPad.Operation.transform0(text, toTransform, transformBy);
        var text2 = ChainPad.Operation.apply(transformBy, text);
        var text3 = ChainPad.Operation.apply(resultOp, text2);
        try {
            JSON.parse(text3);
            return resultOp;
        } catch (e) {
            console.log(e);
        }<commit_msg>better error reporting when the operational transform fails to parse JSON<commit_after>define([
    '/common/realtime-input.js'
], function () {
    var ChainPad = window.ChainPad;
    var JsonOT = {};

    var validate = JsonOT.validate = function (text, toTransform, transformBy) {
        var resultOp = ChainPad.Operation.transform0(text, toTransform, transformBy);
        var text2 = ChainPad.Operation.apply(transformBy, text);
        var text3 = ChainPad.Operation.apply(resultOp, text2);
        try {
            JSON.parse(text3);
            return resultOp;
        } catch (e) {
            console.error(e);
            console.log({
                resultOp: resultOp,
                text2: text2,
                text3: text3
            });
        }
{'fraction_non_alphanumeric': 0.10961968680089486, 'fraction_numerical': 0.010439970171513796, 'mean_word_length': 2.1800947867298577, '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': '2604323', 'n_tokens_mistral': 375, 'n_tokens_neox': 367, 'n_words': 87}