chapter icon indicating copy to clipboard operation
chapter copied to clipboard

User friendly errors and logging

Open ojeytonwilliams opened this issue 3 years ago • 3 comments

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:

image

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

ojeytonwilliams avatar Aug 10 '22 10:08 ojeytonwilliams

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 avatar Sep 02 '22 19:09 Sboonny

@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.

ojeytonwilliams avatar Sep 05 '22 10:09 ojeytonwilliams

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

Sboonny avatar Oct 06 '22 14:10 Sboonny