Throw a nice error if note contents are missing

This commit is contained in:
Juan Cruz Viotti 2015-04-29 14:39:46 -04:00
parent faecf103bf
commit fab85b381a
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,7 @@
(function() {
var async, resin;
var _, async, resin;
_ = require('lodash');
async = require('async');
@ -20,6 +22,9 @@
],
permission: 'user',
action: function(params, options, done) {
if (_.isEmpty(params.note)) {
return done(new Error('Missing note content'));
}
return resin.models.device.note(options.device, params.note, done);
}
};

View File

@ -1,3 +1,4 @@
_ = require('lodash')
async = require('async')
resin = require('resin-sdk')
@ -25,4 +26,8 @@ exports.set =
]
permission: 'user'
action: (params, options, done) ->
if _.isEmpty(params.note)
return done(new Error('Missing note content'))
resin.models.device.note(options.device, params.note, done)