How to use the InternalError function from restify

Find comprehensive JavaScript restify.InternalError code examples handpicked from public code repositorys.

227
228
229
230
231
232
233
234
235
236
backend.getWorkflows(req.params, function (err, workflows) {
    if (err) {
        if (err.toRestError) {
            return next(err.toRestError);
        } else {
            return next(new restify.InternalError(err));
        }
    }
    res.send(200, workflows);
    return next();
fork icon71
star icon449
watch icon0

+ 10 other calls in file

37
38
39
40
41
42
43
44
45
46
  milestone: require('../models/milestone'),
}

const http403 = restify.NotAuthorizedError
const http404 = restify.ResourceNotFoundError
const http500 = restify.InternalError

function createFinder(modelName, gOpts) {
  return function findModel(opts) {
    opts = opts || {}
fork icon46
star icon0
watch icon2

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;
fork icon24
star icon0
watch icon1

190
191
192
193
194
195
196
197
198
199
        err: error,
        url: req.url,
        params: req.params
    });

    res.send(new restify.InternalError('Internal Server Error'));
});

config.napi.log = log.child({ component: 'napi' }, true);
config.cnapi.log = log.child({ component: 'cnapi' }, true);
fork icon20
star icon0
watch icon1

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
        return new restify.InternalError(err, errMsg);
    }
}




samples.InternalError = new restify.InternalError('boom');






//---- exports
fork icon17
star icon5
watch icon0

+ 5 other calls in file

94
95
96
97
98
99
100
101
102
103

/*
 * Returns a handler that will log uncaught exceptions properly
 */
function uncaughtHandler(req, res, route, err) {
    res.send(new mod_restify.InternalError(err, 'Internal error'));
    /**
     * We don't bother logging the `res` here because it always looks like
     * the following, no added info to the log.
     *
fork icon12
star icon0
watch icon2

110
111
112
113
114
115
116
117
118
119
    res.send(409, errors);
    return (false);
};

if (!self.ufds_client) {
    next(new restify.InternalError('Upstream server down'));
} else {
    req.ufds = self.ufds_client;
    next();
}
fork icon8
star icon6
watch icon0

59
60
61
62
63
64
65
66
67
68
    }
    return error;
}

function InternalError(msg , outMsg){
    var error = new restify.InternalError(msg);
    if(outMsg){
        error.body.outMsg = outMsg;
    }
    return error;
fork icon0
star icon0
watch icon0

+ 3 other calls in file