How to use the INTERNAL_SERVER_ERROR function from http-status-codes

Find comprehensive JavaScript http-status-codes.INTERNAL_SERVER_ERROR code examples handpicked from public code repositorys.

88
89
90
91
92
93
94
95
96
97
98
app.use((err, req, res, next) => {
  logger.logFullError(err, req.signature || `${req.method} ${req.url}`);
  const errorResponse = {};
  let status = err.isJoi
    ? HttpStatus.BAD_REQUEST
    : err.httpStatus || _.get(err, "response.status") || HttpStatus.INTERNAL_SERVER_ERROR;


  // Check if err is a GrpcError
  if (err.details != null && err.code != null) {
    status = err.code == 5 ? HttpStatus.NOT_FOUND : HttpStatus.BAD_REQUEST; // TODO: Use @topcoder-framework/lib-common to map GrpcError codes to HTTP codes
fork icon44
star icon17
watch icon25

+ 4 other calls in file

1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
}


function grpcErrorToHTTPCode(grpcErrorCode) {
  if (grpcErrorCode == 2) return HttpStatus.NOT_FOUND;


  return HttpStatus.INTERNAL_SERVER_ERROR;
}


module.exports = {
  wrapExpress,
fork icon44
star icon17
watch icon25

+ 4 other calls in file

227
228
229
230
231
232
233
234
235
236
      result.accessToken = response.data.access_token;
      result.refreshToken = response.data.refresh_token;
      return result;
    } catch (error) {
      log.error('getApiCredentials Error', error.response ? pick(error.response, ['status', 'statusText', 'data']) : error.message);
      const status = error.response ? error.response.status : HttpStatus.INTERNAL_SERVER_ERROR;
      throw new ApiError(status, {message: 'Get getApiCredentials error'}, error);
    }
  }
};
fork icon5
star icon5
watch icon10

+ 15 other calls in file

32
33
34
35
36
37
38
39
40
41
42
43
}


function errorResponse(res, msg, code) {
  return res.status(code || HttpStatus.INTERNAL_SERVER_ERROR).json({
    message: msg || 'INTERNAL SERVER ERROR',
    code: code || HttpStatus.INTERNAL_SERVER_ERROR
  });
}


function addTokenToHeader(params, token) {
fork icon5
star icon5
watch icon10

+ 49 other calls in file