mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
feat: make error messages more clear (#1166)
This commit is contained in:
parent
8a07a8a31d
commit
686612a69d
@ -1,5 +1,4 @@
|
||||
/* eslint-disable max-lines */
|
||||
import axios from "axios";
|
||||
import { UUID } from "crypto";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useCallback, useState } from "react";
|
||||
@ -11,6 +10,7 @@ import { useNotificationApi } from "@/lib/api/notification/useNotificationApi";
|
||||
import { useUploadApi } from "@/lib/api/upload/useUploadApi";
|
||||
import { useChatContext } from "@/lib/context";
|
||||
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
||||
import { getAxiosErrorParams } from "@/lib/helpers/getAxiosErrorParams";
|
||||
import { useToast } from "@/lib/hooks";
|
||||
|
||||
import { FeedItemCrawlType, FeedItemType, FeedItemUploadType } from "../types";
|
||||
@ -68,12 +68,22 @@ export const useKnowledgeUploader = ({
|
||||
});
|
||||
await fetchNotifications(chat_id);
|
||||
} catch (error: unknown) {
|
||||
publish({
|
||||
variant: "danger",
|
||||
text: t("crawlFailed", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
const errorParams = getAxiosErrorParams(error);
|
||||
if (errorParams !== undefined) {
|
||||
publish({
|
||||
variant: "danger",
|
||||
text: t("crawlFailed", {
|
||||
message: JSON.stringify(errorParams.message),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
publish({
|
||||
variant: "danger",
|
||||
text: t("crawlFailed", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
[crawlWebsiteUrl, publish, t]
|
||||
@ -90,21 +100,20 @@ export const useKnowledgeUploader = ({
|
||||
chat_id,
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
if (axios.isAxiosError(e) && e.response?.status === 403) {
|
||||
const errorParams = getAxiosErrorParams(e);
|
||||
if (errorParams !== undefined) {
|
||||
publish({
|
||||
variant: "danger",
|
||||
text: `${JSON.stringify(
|
||||
(
|
||||
e.response as {
|
||||
data: { detail: string };
|
||||
}
|
||||
).data.detail
|
||||
)}`,
|
||||
text: t("uploadFailed", {
|
||||
message: JSON.stringify(errorParams.message),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
publish({
|
||||
variant: "danger",
|
||||
text: t("error", { message: e }),
|
||||
text: t("uploadFailed", {
|
||||
message: JSON.stringify(e),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ export const NotificationDisplayer = ({
|
||||
const { message, status, name } = JSON.parse(
|
||||
nonParsedMessage.replace(/'/g, '"')
|
||||
) as NotificationMessage;
|
||||
console.log({
|
||||
message,
|
||||
status,
|
||||
name,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dragAndDrop":"Drag and drop files here, or click to browse",
|
||||
"webSite": "Insert website URL",
|
||||
"success": "File uploaded successfully",
|
||||
"error": "Failed to upload file: {{message}}",
|
||||
"uploadFailed": "Failed to upload file: {{message}}",
|
||||
"maxSizeError": "File too big",
|
||||
"alreadyAdded": "{{fileName}} was already added",
|
||||
"addFiles": "Please, add files to upload",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"crawlFailed": "Error al rastrear sitio web: {{message}}",
|
||||
"dragAndDrop": "Arrastre y suelte archivos aquí o click para buscar",
|
||||
"drop": "Suelte los archivos aquí...",
|
||||
"error": "Error al subir archivo: {{message}}",
|
||||
"uploadFailed": "Error al subir archivo: {{message}}",
|
||||
"invalidUrl": "URL inválido",
|
||||
"maxSizeError": "Tamaño de archivo excedido",
|
||||
"missingNecessaryRole": "No tienes el rol necesario para cargar contenido en el cerebro seleccionado. 🧠💡🥲",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dragAndDrop": "Glissez et déposez les fichiers ici, ou cliquez pour parcourir",
|
||||
"webSite": "Insérer l'URL du site web",
|
||||
"success": "Fichier téléchargé avec succès",
|
||||
"error": "Échec du téléchargement du fichier : {{message}}",
|
||||
"uploadFailed": "Échec du téléchargement du fichier : {{message}}",
|
||||
"maxSizeError": "Fichier trop volumineux",
|
||||
"alreadyAdded": "{{fileName}} a déjà été ajouté",
|
||||
"addFiles": "Veuillez ajouter des fichiers à télécharger",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dragAndDrop": "Arraste e solte os arquivos aqui, ou clique para procurar",
|
||||
"webSite": "Insira o URL do site",
|
||||
"success": "Arquivo enviado com sucesso",
|
||||
"error": "Falha ao enviar arquivo: {{message}}",
|
||||
"uploadFailed": "Falha ao enviar arquivo: {{message}}",
|
||||
"maxSizeError": "Arquivo muito grande",
|
||||
"alreadyAdded": "{{fileName}} já foi adicionado",
|
||||
"addFiles": "Por favor, adicione arquivos para enviar",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dragAndDrop": "Перетащите файлы сюда или нажмите, чтобы выбрать",
|
||||
"webSite": "Вставьте URL веб-сайта",
|
||||
"success": "Файл успешно загружен",
|
||||
"error": "Не удалось загрузить файл: {{message}}",
|
||||
"uploadFailed": "Не удалось загрузить файл: {{message}}",
|
||||
"maxSizeError": "Файл слишком большой",
|
||||
"alreadyAdded": "{{fileName}} уже добавлен",
|
||||
"addFiles": "Пожалуйста, добавьте файлы для загрузки",
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dragAndDrop": "将文件拖放到此处,或单击浏览",
|
||||
"webSite": "插入网站URL",
|
||||
"success": "文件上传成功",
|
||||
"error": "上传文件失败:{{message}}",
|
||||
"uploadFailed": "上传文件失败:{{message}}",
|
||||
"maxSizeError": "文件太大",
|
||||
"alreadyAdded": "已添加 {{filename}}",
|
||||
"addFiles": "请添加要上传的文件",
|
||||
|
Loading…
Reference in New Issue
Block a user