How to use the baconjs.Error function in baconjs

To help you get started, we’ve selected a few baconjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CleverCloud / clever-tools / src / models / configuration.js View on Github external
.flatMapError((error) => {
      // TODO propagate this
      Logger.info(new Bacon.Error(`Cannot load configuration from ${conf.CONFIGURATION_FILE}\n${error.message}`));
      return {};
    });
}
github rbelouin / fip.rbelouin.com / test / js / models / song.spec.js View on Github external
SongModel.searchOnSpotify = function() {
      return Bacon.once(new Bacon.Error());
    };
github CleverCloud / clever-tools / src / models / addon.js View on Github external
return s_addons.flatMapLatest((addons) => {
    const filtered_addons = _.filter(addons, ({ name, realId }) => {
      return name === addonName || realId === addonName;
    });
    if (filtered_addons.length === 1) {
      return Bacon.once(filtered_addons[0]);
    }
    if (filtered_addons.length === 0) {
      return Bacon.once(new Bacon.Error('Addon not found'));
    }
    return Bacon.once(new Bacon.Error('Ambiguous addon name'));
  });
}
github CleverCloud / clever-tools / src / models / application.js View on Github external
const s_app = s_apps.flatMapLatest(function (apps) {
    const filtered_apps = _.filter(apps, function (app) {
      return app.name === name;
    });
    if (filtered_apps.length === 1) {
      return Bacon.once(filtered_apps[0]);
    }
    else if (filtered_apps.length === 0) {
      return Bacon.once(new Bacon.Error('Application not found'));
    }
    else {
      return Bacon.once(new Bacon.Error('Ambiguous application name'));
    }
  });
github rbelouin / fip.rbelouin.com / src / js / models / http.js View on Github external
export function parseResponse(res) {
  const contentType = res.headers.get("Content-Type");
  const mimeType = contentType && contentType.split(";")[0];
  const isJson = mimeType === "application/json";

  return res.ok && isJson
    ? Bacon.fromPromise(res.json())
    : res.ok
    ? Bacon.once(res)
    : Bacon.once(new Bacon.Error(res));
}
github CleverCloud / clever-tools / src / models / addon.js View on Github external
.flatMapLatest((providers) => {
      const provider = _.find(providers, { id: providerName });
      return provider || new Bacon.Error('invalid provider name');
    });
}
github digabi / rich-text-editor / src / clipboard.js View on Github external
const SCREENSHOT_LIMIT_ERROR = () => new Bacon.Error('Screenshot limit reached!')
const fileTypes = ['image/png', 'image/jpeg']
github rbelouin / fip.rbelouin.com / src / js / models / song.js View on Github external
onmessage: function(message) {
        try {
          var data = JSON.parse(message.data);
          sink(data.type === "song" ? data.song : new Bacon.Error(data.error));
        }
        catch(e) {
          sink(new Bacon.Error(e));
        }
      },
      onerror: function(error) {
github CleverCloud / clever-tools / src / models / events.js View on Github external
          onError: (error) => sink(new Bacon.Error(error)),
          infinite: false,
github CleverCloud / clever-tools / src / models / ws-stream.js View on Github external
ws.on('error', () => {
      Logger.debug('WebSocket error.');
      stopPing();
      sink(new Bacon.Error('WebSocket error.'));
    });