MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / httpStatusCode

Function httpStatusCode

pkg/webui/lib/errors/utils.js:110–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 * `undefined`.
109 */
110export const httpStatusCode = error => {
111 if (!Boolean(error)) {
112 return undefined
113 }
114
115 let statusCode = undefined
116 if (isBackend(error)) {
117 statusCode = error.http_code || grpcErrToHttpErr(error.code || error.grpc_code)
118 } else if (isFrontend(error)) {
119 statusCode = error.statusCode
120 } else if (Boolean(error.statusCode)) {
121 statusCode = error.statusCode
122 } else if (Boolean(error.response) && Boolean(error.response.status)) {
123 statusCode = error.response.status
124 } else if (isObject(error) && error.cause) {
125 return httpStatusCode(error.cause)
126 }
127
128 return Boolean(statusCode) ? parseInt(statusCode) : undefined
129}
130/**
131 * Returns the GRPC Status code in case of a backend error.
132 *

Callers 8

index.jsFile · 0.90
isNotFoundErrorFunction · 0.85
isInvalidArgumentErrorFunction · 0.85
isBadRequestErrorFunction · 0.85
isPermissionDeniedErrorFunction · 0.85
isUnauthenticatedErrorFunction · 0.85
isConflictErrorFunction · 0.85
isSentryWorthyFunction · 0.85

Calls 2

isBackendFunction · 0.85
isFrontendFunction · 0.85

Tested by

no test coverage detected