How to use the errors function from restify
Find comprehensive JavaScript restify.errors code examples handpicked from public code repositorys.
GitHub: fortnotes/server
147 148 149 150 151 152 153 154 155 156
// update note note.save({data: params.data, hash: params.hash, updateTime: time}, function ( error ) { if ( error ) { debug(error); return callback(new restify.errors.InternalServerError('data saving failure')); } callback(null, true); });
1
5
3
+ 23 other calls in file
GitHub: MD4/BeBeerAPI
19 20 21 22 23 24 25 26 27 28
console.log('[REQUEST] %s:%s', controllerName, actionName); if(actionConfig.visibility === MethodVisibility.PRIVATE) { if (!AuthController.getAuthUser(req)) return next(new restify.errors.UnauthorizedError('You must be logged in to do this.')); } // Input validator var validation = revalidator.validate(
1
3
2
GitHub: r26D/FabMo-Engine
7 8 9 10 11 12 13 14 15
var escapeRE = require('escape-regexp-component'); var exec = require('child_process').exec; var mime = require('mime'); var restify = require('restify'); var errors = restify.errors; ALLOWED_EXTENSIONS = ['.nc','.g','.sbp','.gc','.gcode']; ALLOWED_APP_EXTENSIONS = ['.zip', '.fma'];
22
0
4
GitHub: alcmoraes/labs-pickles
29 30 31 32 33 34 35 36 37 38
// Ensure only requests containing "Accept: application/json" headers server.use((req, res, next) => { if (req.xhr || req.headers.hasOwnProperty('accept') && req.headers['accept'].indexOf('application/json') > -1) { return next(); } else { return res.send(new restify.errors.MethodNotAllowedError((typeof err != 'undefined' ? err : "Method not allowed"))) } }); resolve(server);
1
0
1
GitHub: jonkster/recogniser
31 32 33 34 35 36 37 38 39 40
var match = req.body.toString().replace(/^data:([A-Za-z-+\/]+);base64/, ''); var imData = new Buffer(match, "base64"); fs.writeFile(newPath, imData, function (err) { if (err) { var err = new restify.errors.InternalServerError('image file could not be saved'); res.send(err); return next(); } else
0
0
2
+ 3 other calls in file
29 30 31 32 33 34 35 36 37 38
if (hash !== verifyHash) { return next(new restify.errors.BadDigestError('x-signature does not match')) } if (typeof req.body['_source'] === 'undefined') { return next(new restify.errors.MissingParameterError('missing _source parameter in the json body')) } if (typeof req.body['_time'] === 'undefined') { return next(new restify.errors.MissingParameterError('missing _time parameter in the json body')) }
0
0
2
+ 9 other calls in file
restify.createServer is the most popular function in restify (1059 examples)