mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
corrected linking error to NotFoundError
This commit is contained in:
@@ -3,6 +3,7 @@ import { PrismaClientKnownRequestError, PrismaClientUnknownRequestError } from "
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { ZodError } from "zod";
|
import { ZodError } from "zod";
|
||||||
import prisma from "../lib/prisma";
|
import prisma from "../lib/prisma";
|
||||||
|
import NotFoundError from "../Middleware/error/NotFoundError";
|
||||||
|
|
||||||
interface StringIndexedObject {
|
interface StringIndexedObject {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
@@ -151,12 +152,7 @@ export async function handleCreateByName(
|
|||||||
const linked = await prisma[link.type].findUnique({ where: { pid: link.id }, select: { id: true } });
|
const linked = await prisma[link.type].findUnique({ where: { pid: link.id }, select: { id: true } });
|
||||||
|
|
||||||
if (!linked) {
|
if (!linked) {
|
||||||
return res.status(404).json({
|
throw new NotFoundError(link.type, link.id);
|
||||||
type: "error",
|
|
||||||
payload: {
|
|
||||||
message: `Could not link to ${link.type} with ID '${link.id}'`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
Reference in New Issue
Block a user