<commit_before>const request = require('request-promise')

class RemoteComponent {

  /**
   * Construct a remote component
   *
   * @param  {string} url URL of the component
   */
  constructor (url) {
    this._url = url
  }

  get (name) {
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'GET',
        json: true
      })
      .then(function (data) {
        resolve(data)
      })
      .catch(function (error) {
        reject(error)
      })
    })
  }

  set (name, value) {
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'PUT',
        body: value,
        json: true
      })
      .then(function () {
        resolve()
      })
      .catch(function (error) {
        reject(error)
      })
    })
  }

  call (name) {
    let args = Array.prototype.slice.call(arguments, 1)
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'POST',
        body: args,
        json: true
      })
      .then(function (data) {
        resolve(data)
      })
      .catch(function (error) {
        reject(error)
      })
    })
  }

  read (path) {
    return this.call('read', path || null)
  }

  write (path) {
    return this.call('write', path || null)
  }

  save (content, format, path) {
    return this.call('save', content, format, path || null)
  }<commit_msg>Always log errors in case caller forgets to use catch()<commit_after>const request = require('request-promise')

class RemoteComponent {

  /**
   * Construct a remote component
   *
   * @param  {string} url URL of the component
   */
  constructor (url) {
    this._url = url
  }

  get (name) {
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'GET',
        json: true
      })
      .then(function (data) {
        resolve(data)
      })
      .catch(function (error) {
        console.error('Error in remote get: ' + error.error)
        reject(error)
      })
    })
  }

  set (name, value) {
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'PUT',
        body: value,
        json: true
      })
      .then(function () {
        resolve()
      })
      .catch(function (error) {
        console.error('Error in remote set: ' + error.error)
        reject(error)
      })
    })
  }

  call (name) {
    let args = Array.prototype.slice.call(arguments, 1)
    return new Promise((resolve, reject) => {
      request({
        url: this._url + '!' + name,
        method: 'POST',
        body: args,
        json: true
      })
      .then(function (data) {
        resolve(data)
      })
      .catch(function (error) {
        console.error('Error in remote call: ' + error.error)
        reject(error)
      })
    })
  }

  read (path) {
    return this.call('read', path || null)
  }

  write (path) {
    return this.call('write', path || null)
  }

  save (content, format, path) {
    return this.call('save', content, format, path || null)
  }
{'fraction_non_alphanumeric': 0.14927261227071473, 'fraction_numerical': 0.0006325110689437065, 'mean_word_length': 1.8367713004484305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5809896', 'n_tokens_mistral': 1000, 'n_tokens_neox': 981, 'n_words': 244}