Refactor ShowSchedules component and enhance error handling in schedule API

- Simplified the mutation calls in the ShowSchedules component by removing success callbacks, streamlining the code.
- Improved the display logic to conditionally render the HandleSchedules component when schedules are present.
- Enhanced error handling in the runManually mutation within the schedule API, ensuring proper logging and error messaging for better debugging.
This commit is contained in:
Mauricio Siu
2025-05-02 16:16:44 -06:00
parent ef02ba22b5
commit 1f6ba45c12
2 changed files with 28 additions and 18 deletions

View File

@@ -95,8 +95,16 @@ export const scheduleRouter = createTRPCRouter({
runManually: protectedProcedure
.input(z.object({ scheduleId: z.string().min(1) }))
.mutation(async ({ input }) => {
await runCommand(input.scheduleId);
return true;
try {
await runCommand(input.scheduleId);
return true;
} catch (error) {
console.log(error);
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message:
error instanceof Error ? error.message : "Error running schedule",
});
}
}),
});