Skip to content

Commit

Permalink
add MissingAttributes error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Feb 22, 2024
1 parent 27234d4 commit 57f6dc0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class TypeNotFound {
}
}
class MissingAttributes {
constructor(msg) {
constructor(msg, device) {
this.name = 'MISSING_ATTRIBUTES';
this.message = 'The request was not well formed:' + msg;
this.message = 'The request was not well formed:' + msg + ' with: ' + +JSON.stringify(device);
}
}
class DeviceNotFound {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/devices/devices-NGSI-LD.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function updateEntityNgsiLD(deviceData, updatedDevice, callback) {
*/
function updateRegisterDeviceNgsiLD(deviceObj, entityInfoUpdated, callback) {
if (!deviceObj.id || !deviceObj.type) {
callback(new errors.MissingAttributes('Id or device missing'));
callback(new errors.MissingAttributes('Id or device missing', deviceObj));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/services/devices/devices-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function updateEntityNgsi2(deviceData, updatedDevice, callback) {
*/
function updateRegisterDeviceNgsi2(deviceObj, entityInfoUpdated, callback) {
if (!deviceObj.id || !deviceObj.type) {
callback(new errors.MissingAttributes('Id or device missing'));
callback(new errors.MissingAttributes('Id or device missing', deviceObj));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/services/northBound/restUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function checkMandatoryQueryParams(mandatoryAttributes, body, callback) {
}

if (missing.length !== 0) {
const error = new errors.MissingAttributes('Missing attributes: ' + JSON.stringify(missing));
const error = new errors.MissingAttributes('Missing attributes: ' + JSON.stringify(missing), body);
error.code = '400';

callback(error);
Expand Down

0 comments on commit 57f6dc0

Please sign in to comment.