mirror of
https://github.com/detleph/server.git
synced 2026-09-09 07:56:18 +02:00
basic errorhandling inconsistancy fix
This commit is contained in:
@@ -72,7 +72,7 @@ export const getEvent = async (req: Request, res: Response) => {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const event = await prisma.event.findUnique({
|
const event = await prisma.event.findUnique({
|
||||||
where: {
|
where: {
|
||||||
pid: eventId,
|
pid: eventId,
|
||||||
@@ -90,29 +90,6 @@ export const getEvent = async (req: Request, res: Response) => {
|
|||||||
event,
|
event,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Prisma.PrismaClientKnownRequestError) {
|
|
||||||
return res.status(500).json({
|
|
||||||
type: "error",
|
|
||||||
payload: {
|
|
||||||
message: `Internal Server error occured. Try again later`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (e instanceof Prisma.PrismaClientUnknownRequestError) {
|
|
||||||
return res.status(500).json({
|
|
||||||
type: "error",
|
|
||||||
payload: {
|
|
||||||
message: "Unknown error occurred with your request. Check if your parameters are correct",
|
|
||||||
schema: {
|
|
||||||
eventId: DataType.UUID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// requires: auth(ELEVATED)
|
// requires: auth(ELEVATED)
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ interface GetGroupQueryParams {
|
|||||||
export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response) => {
|
export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response) => {
|
||||||
const { pid } = req.params;
|
const { pid } = req.params;
|
||||||
|
|
||||||
try {
|
|
||||||
const group: {
|
const group: {
|
||||||
pid: string;
|
pid: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -96,11 +95,9 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
|||||||
}
|
}
|
||||||
: basicGroup,
|
: basicGroup,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return res.status(404).json(generateError(`The group with ID '${pid}' could not be found`));
|
return res.status(404).json(generateError(`The group with ID '${pid}' could not be found`));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
type: "success",
|
type: "success",
|
||||||
payload: {
|
payload: {
|
||||||
@@ -125,13 +122,6 @@ export const getGroup = async (req: Request<GetGroupQueryParams>, res: Response)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof PrismaClientUnknownRequestError) {
|
|
||||||
return res.status(400).json(generateError("Unknown error occured. This could be due to malformed IDs"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.status(500).json(genericError);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// at: POST /api/organisations/:eventPid/groups
|
// at: POST /api/organisations/:eventPid/groups
|
||||||
|
|||||||
Reference in New Issue
Block a user