User friendly errors and logging
User facing errors
Currently, when an error is thrown by the server, that error is sent to the client and displayed
On the client, this looks like:

when the following error is thrown
Invalid `prisma_1.prisma.chapters.findMany()` invocation in /usr/chapter/server/src/controllers/Chapter/resolver.js:23:47 20 const inputs_1 = require("./inputs"); 21 let ChapterResolver = class ChapterResolver { 22 async chapters() { → 23 return await prisma_1.prisma.chapters.findMany() The table `public.chapters` does not exist in the current database.
This is fine in development, but if NODE_ENV=production the user should see something more appropriate. Ideally a genuinely useful message, but a generic "Something went wrong" message should be fine for the MVP.
Developer facing errors
The other side of this is that no errors appear in the server logs, making debugging difficult. It would make sense to integrate Sentry, but the main thing is that unexpected events (like the above failure) should be recorded somewhere.
MVP:
- [x] Hide error details from users in production
Nice to have:
- [ ] Log server errors both in development and production
- [ ] Integrate with Sentry
- [ ] Create a single 'log' function and use it everywhere
If we have a single log function we can do things like redact secrets (https://github.com/freeCodeCamp/chapter/pull/1860) without repeating ourselves too much.
Original discussion https://github.com/freeCodeCamp/chapter/issues/412
Just wondering, about the possibility to experiment with new services like.
- For the backend error handling: https://www.axiom.co/
- For session replay in client side using: https://www.highlight.io/
@Sboonny as much as possible I'd like to use the same tools as the main repo. We could discuss migrating with Mrugesh, but I don't think we need to experiment with unfamiliar tooling for the MVP.
For documentation: one of the errors to handle in the middle is
- Google calendar integration
An attempt to contact Google calendar's API fails (e.g. when creating an event), it should show a server error