Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
erka committed Nov 25, 2023
1 parent 6beee1b commit 788352d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,19 @@ function isErrorWithMessage(error: unknown): error is ErrorWithMessage {
);
}

function isFetchBaseQueryError(error: unknown): error is ErrorWithMessage {
return (
typeof error === 'object' &&
error !== null &&
'data' in error &&
typeof (error.data as Record<string, unknown>).message === 'string'
);
}

function toErrorWithMessage(maybeError: unknown): ErrorWithMessage {
if (isErrorWithMessage(maybeError)) return maybeError;
// handle Redux FetchBaseQueryError
if (typeof maybeError == 'object' && maybeError?.hasOwnProperty('data')) {
if (isFetchBaseQueryError(maybeError)) {
// @ts-ignore
return maybeError.data;
}
Expand Down

0 comments on commit 788352d

Please sign in to comment.