From 5506de202d208690aa03bcaed4f8c36686aa28be Mon Sep 17 00:00:00 2001 From: Beau Raines Date: Sun, 22 Sep 2024 20:55:53 -0700 Subject: [PATCH] feat: error handling when removing non-existent time entry (#196) Adds a try-catch when deleting a time entry so that the error output is "nice" Fixes #195 --- cmds/removeTimeEntry.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmds/removeTimeEntry.mjs b/cmds/removeTimeEntry.mjs index 0cad897..02c14e7 100644 --- a/cmds/removeTimeEntry.mjs +++ b/cmds/removeTimeEntry.mjs @@ -7,6 +7,12 @@ export const builder = {} export const handler = async function (argv) { const client = await Client() - const deleted = await client.timeEntries.delete(argv.id) + let deleted + try { + deleted = await client.timeEntries.delete(argv.id) + } catch (error) { + console.error(error.message) + process.exit(1) + } console.log(`Deleted time entry with id #${argv.id}`) -} + }