How to use the base/utils.error function in base

To help you get started, we’ve selected a few base 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 vizabi / vizabi / src / base / events.js View on Github external
traversePath: function(path) {

    // if there's no path to traverse
    if (typeof path === 'undefined' || utils.isArray(path) && path.length == 0) {
      return this;
    }

    // prepare path to array
    if (typeof path === 'string') {
      path = path.split('.');
    }

    // check if path is an array
    if (!utils.isArray(path)) {
      utils.error('Path is wrong type. Path should be a string or array but is ' + typeof path + '.');
      return null;
    }

    // descent to next child to find target object
    var currentTarget = path.shift();
    if (this[currentTarget] === undefined)
      utils.warn('Can\'t find child "' + currentTarget + '" of the model ' + this._name + '.');
    else
      return this.getModelObject(currentTarget).traversePath(path);
  },
github vizabi / vizabi / src / base / datastorage.js View on Github external
columnsMissing.forEach(d => {
                if (query.select.key.indexOf(d) == -1) {
                  utils.warn("Reader result: Column '" + d + "' is missing from '" + query.from + "' data, but it might be ok");
                } else {
                  utils.error("Reader result: Key column '" + d + "' is missing from '" + query.from + "' response", JSON.stringify(query));
                  const err = new Error;
                  err.name = "reader/error/keyColumnMissingInReaderResult";
                  err.message = "Reader result: Key column '" + d + "' is missing from '" + query.from + "' response";
                  err.details = d;
                  err.ddfql = query;

                  this.defer.reject(err);
                  console.log(response);
                }
              });
            }
github vizabi / vizabi / src / base / component.js View on Github external
init(config, parent) {
    this._id = this._id || utils.uniqueId("c");
    this._ready = false;
    this._readyOnce = false;
    this.name = this.name || config.name || this._id;
    this.template = this.template || "<div></div>";
    this.placeholder = this.placeholder || config.placeholder;
    this.template_data = this.template_data || {
      name: this.name
    };
    //make sure placeholder is DOM element
    if (this.placeholder &amp;&amp; !utils.isElement(this.placeholder)) {
      try {
        this.placeholder = parent.placeholder.querySelector(this.placeholder);
      } catch (e) {
        utils.error("Error finding placeholder '" + this.placeholder + "' for component '" + this.name + "'");
      }
    }
    this.parent = parent || null;
    this.root = this.parent ? this.parent.root : this;

    this.components = this.components || [];
    this._components_config = this.components.map(x =&gt; utils.clone(x));

    //define expected models for this component
    this.model_expects = this.model_expects || [];
    this.model_binds   = this.model_binds || {};
    this.createModel(config.model);

    this.ui = this.model.ui || this.ui || config.ui;
    this._super();
github vizabi / vizabi / src / readers / waffle / waffle.js View on Github external
_readCallbackSuccess: function (p, path, query, resp) {

    if (!resp) {
      utils.error("Empty json: " + path);
      p.reject({
        'message' : this.ERROR_RESPONSE,
        'data': path
      });
      return;
    }

    //format data
    resp = utils.mapRows(this._uzip(resp.data || resp), this._parsers);

    //cache and resolve
    FILE_CACHED[path] = resp;

    this._parse(p, query, resp);
    FILE_REQUESTED[path] = void 0;
  },
github vizabi / vizabi / src / readers / json / json.js View on Github external
d3.json(path, function(error, res) {

          if(!res) {
            utils.error("No permissions or empty file: " + path, error);
            return;
          }

          if(error) {
            utils.error("Error Happened While Loading JSON File: " + path, error);
            return;
          }
          //fix JSON response
          res = format(res);

          //cache and resolve
          FILE_CACHED[path] = res;
          FILE_REQUESTED[path].resolve();
          FILE_REQUESTED[path] = void 0;

          parse(res);
        });
        FILE_REQUESTED[path] = new Promise();
github vizabi / vizabi / src / readers / json / json.js View on Github external
init: function(reader_info) {
    this._name = 'json';
    this._data = [];
    this._basepath = reader_info.path;
    this._parsers = reader_info.parsers;
    if(!this._basepath) {
      utils.error("Missing base path for json reader");
    };
  },
github vizabi / vizabi / src / readers / graph / graph.js View on Github external
init: function (reader_info) {
    this._name = 'graph';
    this._data = [];
    this._basepath = reader_info.path;
    this._parsers = reader_info.parsers;
    if (!this._basepath) {
      utils.error("Missing base path for graph reader");
    }
  },
github vizabi / vizabi / src / base / component.js View on Github external
utils.forEach(this._components_config, component_config => {

      component_config.model = component_config.model || {};

      if (!component_config.component) {
        utils.error("Error loading component: name not provided");
        return;
      }

      comp = (utils.isString(component_config.component)) ? Component.get(component_config.component) : component_config.component;

      if (!comp) return;

      config = utils.extend(component_config, {
        name: component_config.component,
        ui: _this._uiMapping(component_config.placeholder, component_config.ui)
      });
      //instantiate new subcomponent
      const subcomp = new comp(config, _this);
      _this.components.push(subcomp);
    });
  },
github vizabi / vizabi / src / readers / waffle / waffle.js View on Github external
_readCallbackSuccess: function (p, path, query, resp) {

    if (!resp) {
      utils.error("Empty json: " + path);
      p.reject({
        'message' : this.ERROR_RESPONSE,
        'data': path
      });
      return;
    }
    
    if(path.indexOf("?geo.cat=world_4region&amp;select=geo,geo.name,shape_lores_svg")&gt;-1) {
      utils.warn("WAFFLE READER: APPLYING STUB FUNCTIONALITY TO GET DATA world_4region, WHICH IS NOT YET IN WS");
      resp.rows = [[
          "africa",
          "Africa",
          "<svg viewBox="0 0 584.5 364.5" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M322.7,114.7l-1-1.8l-6.5,2.3l-16-4.8l-2.3,1.7l-1.8,4.5l-16.9-8.6l-0.2-0.6l-0.3-5.5l-2-2.8l-29,4.4l-0.2-0.4 l-1.7,0.2l-0.1,1.1l-6.7,7l-0.5,1.9l-0.6,0.7l-0.3,3.3l-15.3,23.7l0.6,13.2l-1.4,3l1.1,7.6l12.1,17.9l6,2.8l7.1-1.9l4.5,0.8 l13.7-3.3l3.9,4.5h3.5l1.6,1.4l1.8,3.6l-1.1,10.7l9.2,27.4l-4,14.6l8.5,30.7l1.1,1.1v0.7h0.5l3.5,12.5l2,1.7l11.9-0.6l15-18.2v-3.9 l5.1-4.5l1.1-4.2l-1.1-5.9l10.5-12.2l0.6-0.3l1.6-3.7l-3.4-24l25-43.3l-13.1,1.1l-1.8-1.1l-24.7-48.6l0.9-0.4l0.6-1L322.7,114.7  M360.1,233.2l2.3,1.7l-8.6,30.5l-4.3-0.6l-2-7.6l2.8-14.6l6.4-4.4l2.8-4.9L360.1,233.2z" id="africa"></path></svg>"
        ],[
          "americas",
          "Americas",
github vizabi / vizabi / src / base / model.js View on Github external
triggerLoadError(error) {
    EventSource.unfreezeAll();
    this._root.trigger("load_error", error);
    utils.error(error);
  },