Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: update type signature of getErrorDetail
  • Loading branch information
Parkreiner committed Jul 2, 2024
commit 6935f507edb1d97f3d60f496bc81f0b4e164f43a
11 changes: 7 additions & 4 deletions site/src/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ export const getValidationErrorMessage = (error: unknown): string => {
return validationErrors.map((error) => error.detail).join("\n");
};

export const getErrorDetail = (error: unknown): string | null => {
export const getErrorDetail = (error: unknown): string | undefined => {
if (error instanceof Error) {
return "Please check the developer console for more details.";
}

if (isApiError(error)) {
return error.response.data.detail ?? null;
return error.response.data.detail;
}

if (isApiErrorResponse(error)) {
return error.detail ?? null;
return error.detail;
}
return null;

return undefined;
};