diff --git a/app/server/modules/repositories/repositories.service.ts b/app/server/modules/repositories/repositories.service.ts index 1208b7ba..a59c34ba 100644 --- a/app/server/modules/repositories/repositories.service.ts +++ b/app/server/modules/repositories/repositories.service.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; import { eq, or } from "drizzle-orm"; -import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced"; +import { BadRequestError, ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced"; import { db } from "../../db/db"; import { repositoriesTable } from "../../db/schema"; import { toMessage } from "../../utils/errors"; @@ -74,7 +74,7 @@ const createRepository = async ( let shortId: string; if (providedShortId) { if (!isValidShortId(providedShortId)) { - throw new Error(`Invalid shortId format: '${providedShortId}'. Must be 8 base64url characters.`); + throw new BadRequestError(`Invalid shortId format: '${providedShortId}'. Must be 8 base64url characters.`); } const shortIdInUse = await db.query.repositoriesTable.findFirst({ where: eq(repositoriesTable.shortId, providedShortId), @@ -109,7 +109,7 @@ const createRepository = async ( } if (!repoExists && config.isExistingRepository) { - throw new InternalServerError( + throw new BadRequestError( `Cannot access existing repository. Verify the path/credentials are correct and the repository exists.`, ); } diff --git a/app/server/modules/volumes/volume.service.ts b/app/server/modules/volumes/volume.service.ts index 32533fc1..e2a61ea8 100644 --- a/app/server/modules/volumes/volume.service.ts +++ b/app/server/modules/volumes/volume.service.ts @@ -2,7 +2,7 @@ import * as fs from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; import { and, eq, ne } from "drizzle-orm"; -import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced"; +import { BadRequestError, ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced"; import slugify from "slugify"; import { db } from "../../db/db"; import { volumesTable } from "../../db/schema"; @@ -63,7 +63,7 @@ const createVolume = async (name: string, backendConfig: BackendConfig, provided let shortId: string; if (providedShortId) { if (!isValidShortId(providedShortId)) { - throw new Error(`Invalid shortId format: '${providedShortId}'. Must be 8 base64url characters.`); + throw new BadRequestError(`Invalid shortId format: '${providedShortId}'. Must be 8 base64url characters.`); } const shortIdInUse = await db.query.volumesTable.findFirst({ where: eq(volumesTable.shortId, providedShortId),