fix some bugs and enhance error handling

This commit is contained in:
Eng. Elias
2024-03-16 00:40:14 +04:00
parent 79cf073658
commit 7f2315e4fd
5 changed files with 35 additions and 41 deletions

View File

@@ -21,14 +21,13 @@ export function runMission(id) {
"run_mission",
mission
);
if (error) {
throw new Error(message);
if (!error) {
await prisma.mission.update({
where: { id },
data: { result },
});
}
const missionWithResult = prisma.mission.update({
where: { id },
data: { result },
});
return missionWithResult;
return { result, error, message };
} else {
throw Error("Mission doest not exist");
}