How to use the ember-metal/error function in ember-metal

To help you get started, we’ve selected a few ember-metal 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 emberjs / ember.js / packages / ember-application / lib / ext / controller.js View on Github external
dependency = needs[i];

    Ember.assert(inspect(controller) + "#needs must not specify dependencies with periods in their names (" +
                 dependency + ")", dependency.indexOf('.') === -1);

    if (dependency.indexOf(':') === -1) {
      dependency = "controller:" + dependency;
    }

    // Structure assert to still do verification but not string concat in production
    if (!container._registry.has(dependency)) {
      missing.push(dependency);
    }
  }
  if (missing.length) {
    throw new EmberError(inspect(controller) + " needs [ " + missing.join(', ') +
                         " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
  }
}
github emberjs / ember.js / packages / ember-metal / lib / logger.js View on Github external
function assertPolyfill(test, message) {
  if (!test) {
    try {
      // attempt to preserve the stack
      throw new EmberError("assertion failed: " + message);
    } catch(error) {
      setTimeout(() => {
        throw error;
      }, 0);
    }
  }
}
github emberjs / ember.js / packages / ember-handlebars / lib / loader.js View on Github external
.each(function() {
    // Get a reference to the script tag
    var script = jQuery(this);

    var compile = (script.attr('type') === 'text/x-raw-handlebars') ?
                  jQuery.proxy(Handlebars.compile, Handlebars) :
                  jQuery.proxy(EmberHandlebars.compile, EmberHandlebars);
    // Get the name of the script, used by Ember.View's templateName property.
    // First look for data-template-name attribute, then fall back to its
    // id if no name is found.
    var templateName = script.attr('data-template-name') || script.attr('id') || 'application';
    var template = compile(script.html());

    // Check if template of same name already exists
    if (Ember.TEMPLATES[templateName] !== undefined) {
      throw new EmberError('Template named "' + templateName  + '" already exists.');
    }

    // For templates which have a name, we save them and then remove them from the DOM
    Ember.TEMPLATES[templateName] = template;

    // Remove script tag from DOM
    script.remove();
  });
}
github emberjs / ember.js / packages / ember-routing-htmlbars / lib / helpers / render.js View on Github external
Ember.assert(
    "The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.",
    params.length < 2 || isStream(params[1])
  );


  if (params.length === 1) {
    // use the singleton controller
    Ember.assert("You can only use the {{render}} helper once without a model object as its" +
                 " second argument, as in {{render \"post\" post}}.", !router || !router._lookupActiveView(name));
  } else if (params.length === 2) {
    // create a new controller
    initialContext = context.value();
  } else {
    throw new EmberError("You must pass a templateName to render");
  }

  // # legacy namespace
  name = name.replace(/\//g, '.');
  // \ legacy slash as namespace support


  view = container.lookup('view:' + name) || container.lookup('view:default');

  // provide controller override
  var controllerName = hash.controller || name;
  var controllerFullName = 'controller:' + controllerName;

  Ember.assert("The controller name you supplied '" + controllerName +
               "' did not resolve to a controller.", !hash.controller || container.has(controllerFullName));
github emberjs / ember.js / packages / ember-runtime / lib / computed / reduce_computed.js View on Github external
args.forEach(function (dependentKey) {
    if (doubleEachPropertyPattern.test(dependentKey)) {
      throw new EmberError('Nested @each properties not supported: ' + dependentKey);
    } else if (match = eachPropertyPattern.exec(dependentKey)) {
      dependentArrayKey = match[1];

      var itemPropertyKeyPattern = match[2];
      var addItemPropertyKey = function (itemPropertyKey) {
        cp.itemPropertyKey(dependentArrayKey, itemPropertyKey);
      };

      expandProperties(itemPropertyKeyPattern, addItemPropertyKey);
      propertyArgs[guidFor(dependentArrayKey)] = dependentArrayKey;
    } else {
      propertyArgs[guidFor(dependentKey)] = dependentKey;
    }
  });
github emberjs / ember.js / packages / ember-template-compiler / lib / plugins / prevent-render-block.js View on Github external
walker.visit(ast, function(node) {
    if (!validate(node)) { return; }

    throw new Error(assertionMessage(moduleName, node));
  });
github emberjs / ember.js / packages / ember-views / lib / views / simple_bound_view.js View on Github external
rerender() {
    switch (this.state) {
      case 'preRender':
      case 'destroyed':
        break;
      case 'inBuffer':
        throw new EmberError("Something you did tried to replace an {{expression}} before it was inserted into the DOM.");
      case 'hasElement':
      case 'inDOM':
        this.updateId = run.scheduleOnce('render', this, 'update');
        break;
    }
    return this;
  },
github emberjs / ember.js / packages / ember-views / lib / views / container_view.js View on Github external
childViewsDidChange(parentView, views, start, added) {
    throw new EmberError('You cannot modify child views while in the inBuffer state');
  }
});
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / component.js View on Github external
var props = {
    helperName: options.helperName || 'component'
  };
  if (options.template) {
    props.template = options.template;
  }

  var viewClass;
  if (isStream(componentNameParam)) {
    viewClass = BoundComponentView;
    props = { _boundComponentOptions: Ember.merge(hash, props) };
    props._boundComponentOptions.componentNameStream = componentNameParam;
  } else {
    viewClass = readComponentFactory(componentNameParam, container);
    if (!viewClass) {
      throw new EmberError('HTMLBars error: Could not find component named "' + componentNameParam + '".');
    }
    mergeViewBindings(view, props, hash);
  }

  appendTemplatedView(view, options.morph, viewClass, props);
}
github emberjs / ember.js / packages / ember-runtime / lib / controllers / array_controller.js View on Github external
if (subController) {
        return subController;
      }
    }

    if (this._isVirtual) {
      parentController = get(this, 'parentController');
    } else {
      parentController = this;
    }

    fullName = 'controller:' + controllerClass;

    if (!container._registry.has(fullName)) {
      throw new EmberError('Could not resolve itemController: "' + controllerClass + '"');
    }

    subController = container.lookupFactory(fullName).create({
      target: parentController,
      parentController: parentController,
      model: object
    });

    subControllers[idx] = subController;

    return subController;
  },