prisma-client-py icon indicating copy to clipboard operation
prisma-client-py copied to clipboard

Add missing most common errors

Open OMotornyi opened this issue 3 years ago • 3 comments

Problem

There are certain query engine errors that are not mapped to the python client errors. A foreign key violation error would be notable example of a very common error that might require a dedicated handling in the code. Currently we are getting DataError with the following message:

prisma.errors.DataError: Foreign key constraint failed on the field: `some_field_fkey` (index)

Suggested solution

Add proper query engine error mapping to https://github.com/RobertCraigie/prisma-client-py/blob/main/src/prisma/engine/utils.py and corresponding tests:

  • [x] #351
  • [x] #368

Alternatives

The only alternative would be to parse actual error message Foreign key constraint failed on the field which to me feels like a fragile solution.

OMotornyi avatar Apr 01 '22 13:04 OMotornyi

@RobertCraigie I think we can close this now as the associated PR has been merged

jacobdr avatar Oct 24 '22 18:10 jacobdr

Unless we want to keep this open to track full compatibility with upstream errors

jacobdr avatar Oct 24 '22 18:10 jacobdr

@jacobdr Yeah I want to keep this open for now. Not mentioned in the issue description is that we need to investigate what errors are actually exposed upstream to see what we should support, once that is done this issue can be closed.

Here's a link to where most (all?) of the query engine errors are defined.

RobertCraigie avatar Oct 26 '22 18:10 RobertCraigie