Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataProvider delete method only throw Internal Server Error message for errors #523

Open
JasonStrazisar opened this issue Feb 5, 2024 · 0 comments

Comments

@JasonStrazisar
Copy link

API Platform Admin version(s) affected: 3.4.5

Description
Using the useDelete hook, APIP-Admin only throw an 'Internal Server Error' error, even if the API return an error message.
For example, on the API side I have this:

  throw new EntityDeleteForeignKeyException(
      $this->translator->trans(
          'error.entity.my_entity.delete.has_foreign_key',
          [
              '%my_entity%' => $item->value,
              '%entity_linked%' => $this->translator->trans('entity.my_other_entity'),
          ]
      )
  );

This code return a 409 http status code, with the following body:

"@context": "/contexts/Error"
"@type": "hydra:Error"
"hydra:description": "My Error Message"
"hydra:title": "An error occurred"

Wich is at this point the intended behavior so there is no problem.

But then, on the admin side, when we delete the entity and we get a 409 response (in fact, no matter the status code, the result is the same for every HTTP errors), the APIP-admin dataProvider thrown an internal server error and does not take the hydra:description like it do with other methods (PUT, POST, GET...).

This is what is shown in the console when this occurs:

Error
    at new HttpError (HttpError.js:33:23)
    at eval (fetchHydra.js:53:39)

Aditionnal Context:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant