MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / getStatus

Function getStatus

packages/backend/src/errors.ts:10–26  ·  view source on GitHub ↗
(err: unknown)

Source from the content-addressed store, hash-verified

8 * - gitbeaker (GitLab): { cause: { response: { status } } }
9 */
10const getStatus = (err: unknown): number | null => {
11 if (err === null || typeof err !== 'object') {
12 return null;
13 }
14
15 const direct = (err as { status?: unknown }).status;
16 if (typeof direct === 'number') {
17 return direct;
18 }
19
20 const nested = (err as { cause?: { response?: { status?: unknown } } }).cause?.response?.status;
21 if (typeof nested === 'number') {
22 return nested;
23 }
24
25 return null;
26};
27
28export const isUnauthorized = (err: unknown): boolean => getStatus(err) === 401;
29export const isForbidden = (err: unknown): boolean => getStatus(err) === 403;

Callers 3

isUnauthorizedFunction · 0.85
isForbiddenFunction · 0.85
isGoneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected