Skip to content

Commit 90cc1ab

Browse files
Enhance error handling in handleApiThunk to ensure consistent return types
1 parent d072b5c commit 90cc1ab

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/ContentProcessorWeb/src/Services/httpUtility.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export const handleApiThunk = async <T>(
5252
if (response.status === 200 || response.status === 202) {
5353
return response.data as T;
5454
} else {
55-
return rejectWithValue(`${errorMessage}. Status: ${response.status}`);
55+
return rejectWithValue(`${errorMessage}. Status: ${response.status}`) as T;
5656
}
5757
} catch (error: unknown) {
5858
const apiError = error as ApiError;
5959
if (apiError.status === 415 || apiError.status === 404) {
60-
return rejectWithValue(apiError.data?.message || `Unexpected error: ${errorMessage}`);
60+
return rejectWithValue(apiError.data?.message || `Unexpected error: ${errorMessage}`) as T;
6161
}
62-
return rejectWithValue(apiError.message || `Unexpected error: ${errorMessage}`);
62+
return rejectWithValue(apiError.message || `Unexpected error: ${errorMessage}`) as T;
6363
}
6464
};
6565

0 commit comments

Comments
 (0)