api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.42k stars 863 forks source link

Add a way to add an `@id` (hydra) or `type` in errors #4995

Closed nesl247 closed 1 year ago

nesl247 commented 2 years ago

Description
Currently custom errors do not have any identifiable information in them that a frontend application can check. Both Hydra via the @id (https://www.hydra-cg.com/spec/latest/core/#example-32-non-rfc-7807-compliant-error-description-using-raw-hydra-json-ld-representation) and RFC 7807 via type allow for providing an identifier for the type of errors.

This is important as applications need to be able to handle different types of errors in different ways, separately from the HTTP status code. For example, a response may be a 403, but the user may not have access for different reasons. It could be a permission issue, the user isn't enabled, etc.

nesl247 commented 1 year ago

I'm going to close this in favor of #4994 which will need to solve this problem.