When to throw an error?
For example, we
enrich a lot of our data by fetching related or referenced documents. Each ctx.db.get can return null, but this would indicate a business-logic error: a video should not have a channelId which points to a null document. In such a case, we would probably want to entirely dismiss the request and not serve partial data (we keep track of error logs etc. using Axiom).The most straightforward approach in the backend is to
throw new Error in all such cases, but that burdens the client with handling all error casesWhat's an idiomatic or useful approach? We are a startup building a React Native app and are not sure where to place the balance of handling errors. Do we burden the front-end completely with this and keep the backend ncie and deterministic (in terms of return types), or should we couple the backend more closely with error handling?
