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

Function getErrorMessage

site/src/api/errors.ts:74–91  ·  view source on GitHub ↗
(
	error: unknown,
	defaultMessage: string,
)

Source from the content-addressed store, hash-verified

72 * @returns error's message if ApiError or Error, else defaultMessage
73 */
74export const getErrorMessage = (
75 error: unknown,
76 defaultMessage: string,
77): string => {
78 // if error is API error
79 // 404s result in the default message being returned
80 if (isApiError(error) && error.response.data.message) {
81 return error.response.data.message;
82 }
83 if (isApiErrorResponse(error)) {
84 return error.message;
85 }
86 // if error is a non-empty string
87 if (error && typeof error === "string") {
88 return error;
89 }
90 return defaultMessage;
91};
92
93/**
94 *

Callers 15

NotificationsInboxFunction · 0.90
WorkspaceErrorDialogFunction · 0.90
handleErrorFunction · 0.90
TaskPromptLoadingErrorFunction · 0.90
onSubmitFunction · 0.90
TasksSidebarGroupFunction · 0.90
TaskSidebarMenuItemFunction · 0.90
TaskDeleteDialogFunction · 0.90
RoleSelectorFunction · 0.90
InnerAutocompleteFunction · 0.90

Calls 2

isApiErrorFunction · 0.85
isApiErrorResponseFunction · 0.85

Tested by

no test coverage detected