mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-24 05:55:13 +03:00
c5a7b8faef
* feat: update header * feat: remove selected prompt / brain on backspace * feat(chat): update suggestions component * refactor: add getAxiosErrorParams
23 lines
460 B
TypeScript
23 lines
460 B
TypeScript
import { AxiosResponse, isAxiosError } from "axios";
|
|
|
|
type AxiosErrorParams = {
|
|
message: string;
|
|
status: number;
|
|
};
|
|
export const getAxiosErrorParams = (
|
|
e: unknown
|
|
): AxiosErrorParams | undefined => {
|
|
if (isAxiosError(e) && e.response?.data !== undefined) {
|
|
return {
|
|
message: (
|
|
e.response as AxiosResponse<{
|
|
detail: string;
|
|
}>
|
|
).data.detail,
|
|
status: e.response.status,
|
|
};
|
|
}
|
|
|
|
return undefined;
|
|
};
|