sveltejs / api.svelte.dev

The API worker source for https://api.svelte.dev
14 stars 4 forks source link

Propagate errors #17

Closed Rich-Harris closed 2 years ago

Rich-Harris commented 2 years ago

While looking into changing how auth works (tl;dr the app really needs to be responsible for auth, I think, so that it's possible to SSR user content), I found myself getting a bit lost in the codebase because of how errors are handled, which is to say they're not — any database operation returns true or false (or in the case of .get, a non-boolean value or false).

As well as making things (subjectively!) harder to follow, this results in more code, harder-to-track errors, and more convoluted types (I found the Thing | void return types to be problematic in my tinkering).