add PositionNotFound
This commit is contained in:
parent
059b5d515a
commit
a9ff25c771
7
api.js
7
api.js
|
@ -53,7 +53,12 @@ function getInfoDevice(deviceId) {
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then(json => json)
|
.then((json) => {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(json, 'position')) {
|
||||||
|
throw new Error('PositionNotFound');
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
logger.logError(err);
|
logger.logError(err);
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -97,6 +97,11 @@ function devicesNotFound(data) {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function positionNotFound() {
|
||||||
|
const msg = 'Position not found';
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.unauthorizedUser = unauthorizedUser;
|
module.exports.unauthorizedUser = unauthorizedUser;
|
||||||
module.exports.welcome = welcome;
|
module.exports.welcome = welcome;
|
||||||
module.exports.help = help;
|
module.exports.help = help;
|
||||||
|
@ -107,3 +112,4 @@ module.exports.addDeviceHeader = addDeviceHeader;
|
||||||
module.exports.addDeviceBody = addDeviceBody;
|
module.exports.addDeviceBody = addDeviceBody;
|
||||||
module.exports.error = error;
|
module.exports.error = error;
|
||||||
module.exports.devicesNotFound = devicesNotFound;
|
module.exports.devicesNotFound = devicesNotFound;
|
||||||
|
module.exports.positionNotFound = positionNotFound;
|
||||||
|
|
3
utils.js
3
utils.js
|
@ -8,6 +8,9 @@ function sendErrorMessage(error, msgBot) {
|
||||||
case 'DeviceNotFound':
|
case 'DeviceNotFound':
|
||||||
msgBot.reply.text(templates.devicesNotFound(msgBot.text));
|
msgBot.reply.text(templates.devicesNotFound(msgBot.text));
|
||||||
break;
|
break;
|
||||||
|
case 'PositionNotFound':
|
||||||
|
msgBot.reply.text(templates.positionNotFound());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
msgBot.reply.text(templates.error());
|
msgBot.reply.text(templates.error());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue