Doist / todoist-api-typescript

A TypeScript wrapper for the Todoist REST API.
MIT License
71 stars 9 forks source link

Considering wrapping data in results to handler errors more gracefully #239

Open Lilja opened 1 year ago

Lilja commented 1 year ago

Enhancement description

I would much rather deal with the result pattern of data, instead of having to try-catch every single function to handle errors.

// Now
const getTasks = (): Promise<Task[]> => {}
// Desired
const getTasks = (): Promise<Result<Task[], Error>> => {}

The problem it solves

At this very moment, I'm using this SDK to query tasks from my todoist account. It would seem like the Todoist API is returning 502 errors, which are just being thrown as exceptions.

bild
henningmu commented 1 year ago

Thank you for the proposal, @Lilja. We currently don't have plans to add support for this, but will consider it in a future version 🙌