Skip to content

Commit

Permalink
feat: error handling when removing non-existent time entry (#196)
Browse files Browse the repository at this point in the history
Adds a try-catch when deleting a time entry so that the error output is "nice"

Fixes #195
  • Loading branch information
beauraines authored Sep 23, 2024
1 parent 0c3de0f commit 5506de2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmds/removeTimeEntry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}

0 comments on commit 5506de2

Please sign in to comment.