diff --git a/frontend/src/api/tus.ts b/frontend/src/api/tus.ts index fbfef4da..9f86c202 100644 --- a/frontend/src/api/tus.ts +++ b/frontend/src/api/tus.ts @@ -55,12 +55,20 @@ export async function upload( return true; }, - onError: function (error) { + onError: function (error: Error | tus.DetailedError) { if (CURRENT_UPLOAD_LIST[filePath].interval) { clearInterval(CURRENT_UPLOAD_LIST[filePath].interval); } delete CURRENT_UPLOAD_LIST[filePath]; - reject(new Error(`Upload failed: ${error.message}`)); + + const message = + error instanceof tus.DetailedError + ? error.originalResponse === null + ? "000 No connection" + : error.originalResponse.getBody() + : "Upload failed"; + + reject(new Error(message)); }, onProgress: function (bytesUploaded) { const fileData = CURRENT_UPLOAD_LIST[filePath]; diff --git a/frontend/src/views/Files.vue b/frontend/src/views/Files.vue index 370dac53..9d4941a6 100644 --- a/frontend/src/views/Files.vue +++ b/frontend/src/views/Files.vue @@ -26,6 +26,7 @@ import { computed, defineAsyncComponent, + inject, onBeforeUnmount, onMounted, onUnmounted, @@ -50,6 +51,8 @@ import { name } from "../utils/constants"; const Editor = defineAsyncComponent(() => import("@/views/files/Editor.vue")); const Preview = defineAsyncComponent(() => import("@/views/files/Preview.vue")); +const $showError = inject("$showError")!; + const layoutStore = useLayoutStore(); const fileStore = useFileStore(); const uploadStore = useUploadStore(); @@ -117,7 +120,7 @@ watch(reload, (newValue) => { newValue && fetchData(); }); watch(uploadError, (newValue) => { - newValue && layoutStore.showError(); + newValue && $showError(newValue); }); // Define functions