Skip to content

Commit

Permalink
fix: add error handling for uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Oct 11, 2022
1 parent ffd538f commit e2b3e6a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/src/pages/upload.tsx
@@ -1,5 +1,6 @@
import { Button, Group } from "@mantine/core";
import { useModals } from "@mantine/modals";
import axios from "axios";
import { useRouter } from "next/router";
import { useState } from "react";
import Meta from "../components/Meta";
Expand All @@ -11,6 +12,7 @@ import useUser from "../hooks/user.hook";
import shareService from "../services/share.service";
import { FileUpload } from "../types/File.type";
import { ShareSecurity } from "../types/share.type";
import toast from "../utils/toast.util";

const Upload = () => {
const router = useRouter();
Expand Down Expand Up @@ -49,10 +51,15 @@ const Upload = () => {
setFiles([]);
}
}
} catch {
} catch (e) {
files.forEach((file) => {
file.uploadingState = undefined;
});
if (axios.isAxiosError(e)) {
toast.error(e.response?.data?.message ?? "An unkown error occured.");
} else {
toast.error("An unkown error occured.");
}
setFiles([...files]);
setisUploading(false);
}
Expand Down

0 comments on commit e2b3e6a

Please sign in to comment.