Skip to content

Commit

Permalink
add CommandNotFound GroupNotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Feb 22, 2024
1 parent c0ea562 commit af0ae4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TypeNotFound {
class MissingAttributes {
constructor(msg, device) {
this.name = 'MISSING_ATTRIBUTES';
this.message = 'The request was not well formed:' + msg + ' with: ' + +JSON.stringify(device);
this.message = 'The request was not well formed:' + msg + ' with: ' + JSON.stringify(device);
}
}
class DeviceNotFound {
Expand Down Expand Up @@ -219,9 +219,10 @@ class DeviceGroupNotFound {
}
}
class GroupNotFound {
constructor(service, subservice) {
constructor(service, subservice, type) {
this.name = 'GROUP_NOT_FOUND';
this.message = 'Group not found for service [' + service + '] and subservice [' + subservice + ']';
this.message =
'Group not found for service [' + service + '] subservice [' + subservice + '] and type [' + type + ']';
this.code = 404;
}
}
Expand Down
10 changes: 8 additions & 2 deletions lib/services/groups/groupService.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,14 @@ function getEffectiveApiKey(service, subservice, type, callback) {
logger.debug(context, 'Using default API Key: %s', config.getConfig().defaultKey);
callback(null, config.getConfig().defaultKey);
} else {
logger.error(context, 'Could not find any API Key information for device.');
callback(new errors.GroupNotFound(service, subservice));
logger.error(
context,
'Could not find any APIKey information for device in service %s subservice %s and type %s',
service,
subservice,
type
);
callback(new errors.GroupNotFound(service, subservice, type));
}
}

Expand Down

0 comments on commit af0ae4e

Please sign in to comment.