wasp-lang/wasp

Improve Prisma client error code to HTTP status code mapping

Open

#384 aberto em 7 de dez. de 2021

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)Haskell (227 forks)batch import
enhancementhacktoberfestwebdev

Métricas do repositório

Stars
 (4.229 stars)
Métricas de merge de PR
 (Mesclagem média 2d 16h) (85 fundiu PRs em 30d)

Description

When saving things to the database with Prisma, many things can potentially go wrong. We need to indicate them to clients in ways that are actionable when they can correct them (e.g., status code 422 on bad input), or otherwise when they cannot (e.g., status code 500 when things are really wrong on backend).

We currently have a basic helper in place [waspc/data/Generator/templates/server/src/utils.js] that can check if an Error is a Prisma client error, and convert it to an HttpError. It is used during the sign up flow [waspc/data/Generator/templates/server/src/routes/auth/signup.js]. However, the mapping is incomplete. We need to thoroughly review https://www.prisma.io/docs/reference/api-reference/error-reference and determine what HTTP status code/message we should send from the controller to the frontend in each case.

This may also require refactoring the existing helpers, and allowing more flexible uses.

Guia do colaborador