How to use the UnprocessableEntityError function from restify
Find comprehensive JavaScript restify.UnprocessableEntityError code examples handpicked from public code repositorys.
37 38 39 40 41 42 43 44 45 46
if (err.fatal) { return new restify.ServiceUnavailableError('Database Fatal Error: ' + err.code); } else if (err.code === 'ER_DUP_ENTRY') { return new restify.BadRequestError('Request can not accomplished, cause of duplicate entrys in the database'); } return new restify.UnprocessableEntityError('Database query failed: ' + err.code); }; function getPool() { return this.pool;
1
2
2
45 46 47 48 49 50 51 52 53
return next(); } // bad data -> 422 UnprocessableEntityError log.warn('bad data schema -> %s', JSON.stringify(req.body)); return next( new restify.UnprocessableEntityError( config.UNPROCESSABLE_ENTITY_ERROR_MESSAGE)); }
0
1
3
12 13 14 15 16 17 18 19 20 21
var data; try { data = JSON.parse(req.query.data); } catch(e) { return next(new restify.UnprocessableEntityError('Bad Request: malformed JSON in `data` query parameter')); } if(!data.organization || !data.organization.id) { return next(new restify.InvalidCredentialsError('Bad Request: missing organization id'));
1
0
11
50 51 52 53 54 55 56 57 58 59
console.log('this one is not valid, sending 422', req.body) // bad data -> 422 UnprocessableEntityError var msg = 'Invalid post schema.' emitter.emit('error', msg) return next( new restify.UnprocessableEntityError(msg)) } module.exports = function (port, cb) { var server = restify.createServer()
0
1
2
restify.createServer is the most popular function in restify (1059 examples)