mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix error detail in toast
This commit is contained in:
parent
50415450d8
commit
3b6e425e17
@ -365,12 +365,19 @@ export const systemSlice = createSlice({
|
|||||||
state.statusTranslationKey = 'common.statusConnected';
|
state.statusTranslationKey = 'common.statusConnected';
|
||||||
state.progressImage = null;
|
state.progressImage = null;
|
||||||
|
|
||||||
|
let errorDescription = undefined;
|
||||||
|
|
||||||
|
if (action.payload?.status === 422) {
|
||||||
|
errorDescription = 'Validation Error';
|
||||||
|
} else if (action.payload?.error) {
|
||||||
|
errorDescription = action.payload?.error as string;
|
||||||
|
}
|
||||||
|
|
||||||
state.toastQueue.push(
|
state.toastQueue.push(
|
||||||
makeToast({
|
makeToast({
|
||||||
title: t('toast.serverError'),
|
title: t('toast.serverError'),
|
||||||
status: 'error',
|
status: 'error',
|
||||||
description:
|
description: errorDescription,
|
||||||
action.payload?.status === 422 ? 'Validation Error' : undefined,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -60,6 +60,9 @@ type InvokedSessionThunkConfig = {
|
|||||||
const isErrorWithStatus = (error: unknown): error is { status: number } =>
|
const isErrorWithStatus = (error: unknown): error is { status: number } =>
|
||||||
isObject(error) && 'status' in error;
|
isObject(error) && 'status' in error;
|
||||||
|
|
||||||
|
const isErrorWithDetail = (error: unknown): error is { detail: string } =>
|
||||||
|
isObject(error) && 'detail' in error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `SessionsService.invokeSession()` thunk
|
* `SessionsService.invokeSession()` thunk
|
||||||
*/
|
*/
|
||||||
@ -85,6 +88,14 @@ export const sessionInvoked = createAsyncThunk<
|
|||||||
error: (error as any).body.detail,
|
error: (error as any).body.detail,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (isErrorWithDetail(error) && response.status === 403) {
|
||||||
|
return rejectWithValue({
|
||||||
|
arg,
|
||||||
|
status: response.status,
|
||||||
|
error: error.detail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (error)
|
||||||
return rejectWithValue({ arg, status: response.status, error });
|
return rejectWithValue({ arg, status: response.status, error });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user