Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { AsyncThunkResult } from "@/features/Calendars/types/AsyncThunkResult";
|
||||
|
||||
export async function assertThunkSuccess(result: unknown): Promise<void> {
|
||||
if (result === undefined || result === null) {
|
||||
return;
|
||||
}
|
||||
const typed = result as AsyncThunkResult;
|
||||
if (typed?.type?.endsWith("/rejected")) {
|
||||
if (typed.type && typed.type.endsWith("/rejected")) {
|
||||
throw new Error(
|
||||
typed.error?.message || typed.payload?.message || "API call failed"
|
||||
typed.error?.message ?? typed.payload?.message ?? "Thunk was rejected"
|
||||
);
|
||||
}
|
||||
if (typeof typed.unwrap === "function") {
|
||||
|
||||
Reference in New Issue
Block a user