IMPROVE error handling on frontend

This commit is contained in:
2025-06-10 12:12:19 +02:00
parent faaac0abec
commit f79beadb09
5 changed files with 48 additions and 25 deletions

View File

@@ -33,18 +33,15 @@ const ClipEdit = () => {
setDownloadable(false);
const edited = await editFile(id, outputMetadata);
const processed = await processFile(id);
const edited = await editFile(id, outputMetadata, setError);
if (!edited) {
console.log("Failed to edit file");
setError("Failed to edit file. Please check the metadata and try again.");
return;
}
const processed = await processFile(id, setError);
if (!processed) {
console.log("Failed to process file");
setError("Failed to process file. Please try again later.");
return;
}

View File

@@ -8,14 +8,14 @@ const clipUpload = () => {
const [file, setFile] = useState<File | null>(null);
const navigate = useNavigate();
const [noFileError, setNoFileError] = useState(false);
const [error, setError] = useState<null | string>(null);
const press = (() => {
if (file) {
uploadFile(file)
uploadFile(file, setError)
.then(uuid => navigate(`/create/${uuid}`))
.catch(e => console.error(e));
} else {
setNoFileError(true);
setError("Please choose a file");
}
});
@@ -35,9 +35,7 @@ const clipUpload = () => {
Upload
</BlueButton>
{noFileError &&
<label className={"text-center text-red-500"}>Please choose a file</label>
}
<label className={"text-center text-red-500"}>{error}</label>
</Box>
)
};