MCPcopy Index your code
hub / github.com/coder/coder / isApiErrorResponse

Function isApiErrorResponse

site/src/api/errors.ts:29–42  ·  view source on GitHub ↗
(err: unknown)

Source from the content-addressed store, hash-verified

27
28/** @public Exported for use by external consumers (e.g., VS Code extension). */
29export const isApiErrorResponse = (err: unknown): err is ApiErrorResponse => {
30 return (
31 typeof err === "object" &&
32 err !== null &&
33 "message" in err &&
34 typeof err.message === "string" &&
35 (!("detail" in err) ||
36 err.detail === undefined ||
37 typeof err.detail === "string") &&
38 (!("validations" in err) ||
39 err.validations === undefined ||
40 Array.isArray(err.validations))
41 );
42};
43
44export const hasApiFieldErrors = (error: ApiError): boolean =>
45 Array.isArray(error.response.data.validations);

Callers 5

getApiErrorFunction · 0.90
isApiErrorFunction · 0.85
getErrorMessageFunction · 0.85
getErrorDetailFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected