<commit_before>/*jshint esversion: 6 */

let vscode = require('vscode');
let fs = require('fs');
let path = require('path');
let nsRestClient = require('../helpers/netSuiteRestClient');
let codeChangeHelper = require('../helpers/codeChangeHelper');
let uiHelper = require('../helpers/uiHelper');
let netsuiteList = require('../helpers/netsuiteList');
let _ = require('underscore');

function hasError(data, message) {
    if (data.error) {
        
        var errorMessage = message ? message : JSON.parse(data.error.message).message;
        vscode.window.showErrorMessage(errorMessage);
        return true;
    }
    return false;
}

function downloadFileFromNetSuite(file) {
    nsRestClient.getFile(file, function(data) {
        if (hasError(data)) return;

        var relativeFileName = nsRestClient.getRelativePath(file.fsPath);

        fs.writeFile(file.fsPath, data[0].content.toString());
        vscode.window.showInformationMessage('File "' + relativeFileName + '" downloaded.');
    });
}

function uploadFileToNetSuite(file) {
    var fileContent = fs.readFileSync(file.fsPath, 'utf8');

    nsRestClient.postFile(file, fileContent, function(data) {
        if (hasError(data)) return;

        var relativeFileName = nsRestClient.getRelativePath(file.fsPath);
<commit_msg>Trying to catch more kinds of error messages.<commit_after>/*jshint esversion: 6 */

let vscode = require('vscode');
let fs = require('fs');
let path = require('path');
let nsRestClient = require('../helpers/netSuiteRestClient');
let codeChangeHelper = require('../helpers/codeChangeHelper');
let uiHelper = require('../helpers/uiHelper');
let netsuiteList = require('../helpers/netsuiteList');
let _ = require('underscore');

function hasError(data, message) {
    if (data.error) {
        var errorMessage = "";
        if (message) {
            errorMessage = message;
        }
        else {
            try {
                errorMessage = JSON.parse(data.error.message).message;
            }
            catch(ex) {
                errorMessage = data.error.message;
            }
        }
        vscode.window.showErrorMessage(errorMessage);
        return true;
    }
    return false;
}

function downloadFileFromNetSuite(file) {
    nsRestClient.getFile(file, function(data) {
        if (hasError(data)) return;

        var relativeFileName = nsRestClient.getRelativePath(file.fsPath);

        fs.writeFile(file.fsPath, data[0].content.toString());
        vscode.window.showInformationMessage('File "' + relativeFileName + '" downloaded.');
    });
}

function uploadFileToNetSuite(file) {
    var fileContent = fs.readFileSync(file.fsPath, 'utf8');

    nsRestClient.postFile(file, fileContent, function(data) {
        if (hasError(data)) return;

        var relativeFileName = nsRestClient.getRelativePath(file.fsPath);

{'fraction_non_alphanumeric': 0.13368606701940036, 'fraction_numerical': 0.0021164021164021165, 'mean_word_length': 3.296969696969697, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1304967', 'n_tokens_mistral': 835, 'n_tokens_neox': 824, 'n_words': 157}