surface detail field for 403 errors

This commit is contained in:
Mary Hipp 2023-05-08 11:52:35 -04:00 committed by psychedelicious
parent 1809990ed4
commit 853c83d0c2
2 changed files with 22 additions and 8 deletions

View File

@ -384,6 +384,13 @@ export const systemSlice = createSlice({
state.statusTranslationKey = 'common.statusPreparing'; state.statusTranslationKey = 'common.statusPreparing';
}); });
builder.addCase(sessionInvoked.rejected, (state, action) => {
const error = action.payload as string | undefined;
state.toastQueue.push(
makeToast({ title: error || t('toast.serverError'), status: 'error' })
);
});
/** /**
* Session Canceled * Session Canceled
*/ */

View File

@ -101,17 +101,24 @@ export const nodeAdded = createAppAsyncThunk(
*/ */
export const sessionInvoked = createAppAsyncThunk( export const sessionInvoked = createAppAsyncThunk(
'api/sessionInvoked', 'api/sessionInvoked',
async (arg: { sessionId: string }, _thunkApi) => { async (arg: { sessionId: string }, { rejectWithValue }) => {
const { sessionId } = arg; const { sessionId } = arg;
const response = await SessionsService.invokeSession({ try {
sessionId, const response = await SessionsService.invokeSession({
all: true, sessionId,
}); all: true,
});
sessionLog.info({ arg, response }, `Session invoked (${sessionId})`);
sessionLog.info({ arg, response }, `Session invoked (${sessionId})`); return response;
} catch (error) {
return response; const err = error as any;
if (err.status === 403) {
return rejectWithValue(err.body.detail);
}
throw error;
}
} }
); );