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

Function getErrorDetail

site/src/api/errors.ts:107–137  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

105};
106
107export const getErrorDetail = (error: unknown): string | undefined => {
108 if (error instanceof DetailedError) {
109 return error.detail;
110 }
111
112 // APIErrors that are empty still benefit from checking the developer
113 // console if no detail is provided. So only use the detail field if
114 // it is not empty.
115 if (isApiError(error) && error.response.data.detail) {
116 return error.response.data.detail;
117 }
118
119 if (isApiErrorResponse(error) && error.detail) {
120 return error.detail;
121 }
122
123 if (
124 isApiValidationError(error) &&
125 // Ensure that the validations array is not `[]` (empty array).
126 Array.isArray(error.response.data.validations) &&
127 error.response.data.validations.length > 0
128 ) {
129 return getValidationErrorMessage(error);
130 }
131
132 if (error instanceof Error) {
133 return "Please check the developer console for more details.";
134 }
135
136 return undefined;
137};
138
139export const getErrorStatus = (error: unknown): number | undefined => {
140 if (isApiError(error)) {

Callers 15

NotificationsInboxFunction · 0.90
downloadLogsFunction · 0.90
DownloadAgentLogsButtonFunction · 0.90
WorkspaceErrorDialogFunction · 0.90
handleErrorFunction · 0.90
DownloadLogsDialogFunction · 0.90
TaskPromptLoadingErrorFunction · 0.90
onSubmitFunction · 0.90
TaskSidebarMenuItemFunction · 0.90
TaskDeleteDialogFunction · 0.90

Calls 4

isApiErrorFunction · 0.85
isApiErrorResponseFunction · 0.85
isApiValidationErrorFunction · 0.85

Tested by

no test coverage detected