Skip to content

Commit

Permalink
WIP: COMPONENT_NOT_FOUND should be INTERFACE_NOT_FOUND
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed May 7, 2020
1 parent 700fa33 commit b731a5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/container.js
Expand Up @@ -185,7 +185,7 @@ Container.prototype.create = function(id, parent, ecomp, options) {
// Reject with a more informative error message that indicates the
// requiring component. This assists the developer in finding and
// fixing the cause of error.
reject(new ComponentNotFoundError("Unable to create component '" + id + "' required by '" + (parent && parent.id || 'unknown') + "'"));
reject(new ComponentNotFoundError("Unable to create component '" + id + "' required by '" + (parent && parent.id || 'unknown') + "'", id));
} else if (err) {
return reject(err);
}
Expand Down Expand Up @@ -253,7 +253,7 @@ Container.prototype._loadComponent = function(id, cb) {
return cb(null, spec);
}
}
return cb(new ComponentNotFoundError("Cannot find component '" + id + "'"));
return cb(new ComponentNotFoundError("Cannot find component '" + id + "'", id));
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/errors/componentnotfound.js
Expand Up @@ -3,11 +3,12 @@
*
* @api public
*/
function ComponentNotFoundError(message) {
function ComponentNotFoundError(message, iface) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = message;
this.code = 'COMPONENT_NOT_FOUND';
this.code = 'IMPLEMENTATION_NOT_FOUND';
this.interface = iface;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/resolvers/id.js
Expand Up @@ -17,6 +17,8 @@
*/
module.exports = function() {

// TODO: Redo this to search the container for object Ids, and don't impose a naming constraint

return function(id) {
if (/^[\w\-\.\/]+$/.test(id)) {
return id;
Expand Down

0 comments on commit b731a5a

Please sign in to comment.