How to use the ResourceNotFoundError function from restify
Find comprehensive JavaScript restify.ResourceNotFoundError code examples handpicked from public code repositorys.
50 51 52 53 54 55 56 57 58 59
server.del('/api/:id', function (req, res, next) { widget.delete(req.params.id, function(err) { if (err) { console.log(err); return next ( new restify.ResourceNotFoundError(JSON.stringify(err.errors))); } }); res.send(200); return next();
+ 15 other calls in file
18 19 20 21 22 23 24 25 26
var id = req.body.id; var payload = req.body.payload; var operation = req.app.sockets.getSocket('job', id); if (!id || !operation) { return next(new restify.ResourceNotFoundError('Operation not found')); } else if (!payload) { return next(new restify.MissingParameterError('Missing payload')); }
67 68 69 70 71 72 73 74 75 76
* restify.HttpError * restify.RestError * * # The subset of core restify errors that are used. * restify.ForbiddenError * restify.ResourceNotFoundError * ... * * # Customized restify core errors. * UnauthorizedError
191 192 193 194 195 196 197 198 199 200
request.path().substr(baseuri.length)))); if (filename.substr(0, basedir.length) != basedir) { request.log.warn('denying request for file outside of %s', basedir); next(new mod_restify.ResourceNotFoundError()); return; } fileServer(filename, request, response, next);
+ 7 other calls in file
36 37 38 39 40 41 42 43 44 45
badgeInstance: require('../models/badge-instance'), milestone: require('../models/milestone'), } const http403 = restify.NotAuthorizedError const http404 = restify.ResourceNotFoundError const http500 = restify.InternalError function createFinder(modelName, gOpts) { return function findModel(opts) {
26 27 28 29 30 31 32 33 34
var util = require('util'); var semver = require('semver'); var restify = require('restify'), MissingParameterError = restify.MissingParameterError, InvalidArgumentError = restify.InvalidArgumentError, ResourceNotFoundError = restify.ResourceNotFoundError; var resources = require('./resources'); // --- Globals
GitHub: misterdjules/sdc-cloudapi
![misterdjules profile picture](/misterdjules.png?size=40)
50 51 52 53 54 55 56 57 58 59
var InvalidArgumentError = restify.InvalidArgumentError; var MissingParameterError = restify.MissingParameterError; var ResourceNotFoundError = restify.ResourceNotFoundError; var InternalError = restify.InternalError; var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; var MAC_RE = /^[0-9a-f]{12}/i;
47 48 49 50 51 52 53 54 55 56
}); } res.send(thread_list); return next(); } else { return next(new restify.ResourceNotFoundError("Could not find any such thread")); } }; if('_id' in req.params) {
+ 3 other calls in file
59 60 61 62 63 64 65 66 67
} req.vm = common.translateVm(vm, true); next(); } else { next(new restify.ResourceNotFoundError('VM not found')); } } };
GitHub: FabMo/FabMo-Engine
23 24 25 26 27 28 29 30 31 32 33 34
const GCODE_EXTENSIONS = [".nc", ".g", ".gc", ".gcode"]; const OPENSBP_EXTENSIONS = [".sbp", ".sbc"]; var MethodNotAllowedError = errors.MethodNotAllowedError; var NotAuthorizedError = errors.NotAuthorizedError; var ResourceNotFoundError = errors.ResourceNotFoundError; function listify(x) { if (x instanceof Array) { return x;
591 592 593 594 595 596 597 598 599 600
} else if (err.name === 'DownloadError') { // Docker registry client download error. return new DownloadError(err, errMsg); } else if (err.name === 'NotFoundError') { // Docker registry client image not found error. return new restify.ResourceNotFoundError(err, errMsg); } else if (err.name === 'UnauthorizedError') { // Docker registry client unauthorized error. return new restify.UnauthorizedError(err, errMsg); } else {
54 55 56 57 58 59 60 61 62 63
return next(); }); server.get({path: '/eggs/:uuid', name: 'GetEgg'}, function (req, res, next) { var egg = eggs[req.params.uuid]; if (!egg) { return next(new restify.ResourceNotFoundError('No such egg.')); } res.send(egg); return next(); });
69 70 71 72 73 74 75 76 77 78 79
function serve_get_set(req, res, next) { var set = req.params['set']; if (!(set in pkg_sets)) return (next(new mod_restify.ResourceNotFoundError( sprintf('%s is not a valid package set', set)))); res.send(pkg_sets[set]); return (next()); }
+ 35 other calls in file
51 52 53 54 55 56 57 58 59 60
} return error; } function ResourceNotFoundError(msg , outMsg){ var error = new restify.ResourceNotFoundError(msg); if(outMsg){ error.body.outMsg = outMsg; } return error;
+ 3 other calls in file
restify.createServer is the most popular function in restify (1059 examples)