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
44
17
25
+ 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,
44
17
25
+ 4 other calls in file
GitHub: bcgov/EDUC-STUDENT-ADMIN
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); } } };
5
5
10
+ 15 other calls in file
GitHub: bcgov/EDUC-STUDENT-ADMIN
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) {
5
5
10
+ 49 other calls in file
http-status-codes.StatusCodes is the most popular function in http-status-codes (2750 examples)