Manav Rathi 1 год назад
Родитель
Сommit
c8089fbb60

+ 0 - 4
desktop/src/constants/errors.ts

@@ -15,12 +15,8 @@
 export const CustomErrors = {
     WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED:
         "Windows native image processing is not supported",
-    INVALID_OS: (os: string) => `Invalid OS - ${os}`,
-    WAIT_TIME_EXCEEDED: "Wait time exceeded",
     UNSUPPORTED_PLATFORM: (platform: string, arch: string) =>
         `Unsupported platform - ${platform} ${arch}`,
     MODEL_DOWNLOAD_PENDING:
         "Model download pending, skipping clip search request",
-    INVALID_FILE_PATH: "Invalid file path",
-    INVALID_CLIP_MODEL: (model: string) => `Invalid Clip model - ${model}`,
 };

+ 2 - 2
desktop/src/services/clipService.ts

@@ -245,14 +245,14 @@ async function computeImageEmbedding_(
     inputFilePath: string,
 ): Promise<Float32Array> {
     if (!existsSync(inputFilePath)) {
-        throw Error(CustomErrors.INVALID_FILE_PATH);
+        throw new Error("Invalid file path");
     }
     if (model === Model.GGML_CLIP) {
         return await computeGGMLImageEmbedding(inputFilePath);
     } else if (model === Model.ONNX_CLIP) {
         return await computeONNXImageEmbedding(inputFilePath);
     } else {
-        throw Error(CustomErrors.INVALID_CLIP_MODEL(model));
+        throw new Error(`Invalid CLIP model ${model}`);
     }
 }
 

+ 1 - 2
desktop/src/services/ffmpeg.ts

@@ -1,7 +1,6 @@
 import pathToFfmpeg from "ffmpeg-static";
 import { existsSync } from "node:fs";
 import fs from "node:fs/promises";
-import { CustomErrors } from "../constants/errors";
 import { writeStream } from "../main/fs";
 import log from "../main/log";
 import { execAsync } from "../main/util";
@@ -146,7 +145,7 @@ const promiseWithTimeout = async <T>(
     } = { current: null };
     const rejectOnTimeout = new Promise<null>((_, reject) => {
         timeoutRef.current = setTimeout(
-            () => reject(Error(CustomErrors.WAIT_TIME_EXCEEDED)),
+            () => reject(new Error("Operation timed out")),
             timeout,
         );
     });

+ 2 - 2
desktop/src/services/imageProcessor.ts

@@ -153,7 +153,7 @@ function constructConvertCommand(
             },
         );
     } else {
-        throw Error(CustomErrors.INVALID_OS(process.platform));
+        throw new Error(`Unsupported OS ${process.platform}`);
     }
     return convertCmd;
 }
@@ -289,7 +289,7 @@ function constructThumbnailGenerationCommand(
                 return cmdPart;
             });
     } else {
-        throw Error(CustomErrors.INVALID_OS(process.platform));
+        throw new Error(`Unsupported OS ${process.platform}`);
     }
     return thumbnailGenerationCmd;
 }