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

Error handling? #19

Open
drewclauson opened this issue Oct 23, 2015 · 2 comments
Open

Error handling? #19

drewclauson opened this issue Oct 23, 2015 · 2 comments

Comments

@drewclauson
Copy link
Contributor

What type of strategy would be best for error handling? I'm not exactly sure how to go about it, but I'd be open to trying it if anyone has suggestions on how best to do it.

@koemeet
Copy link
Owner

koemeet commented Mar 13, 2016

@drewclauson If you are using symfony forms, overriding JMS\Serializer\Handler\FormErrorHandler is I think the best way. In here you can manipulate it in every way you want. I need proper json-api error handling soon (in 1-2 weeks), so it will be supported by this bundle.

@chernecov
Copy link
Contributor

chernecov commented Jan 14, 2018

@koemeet
Error handling can be split into two situations:

  1. Application error (Exception)
  2. Validation Errors (Violation List)

We can use KernelEvents::EXCEPTION to handle application errors.

{
  "errors": [
    {
      "title": "Uncaught exception was thrown",
      "detail": "No route found for \"GET /wrong\""
    }
  ]
}

And serialize ConstraintViolationListInterface and ConstraintViolation to:

{
  "errors": [
    {
      "title": "Validation failed",
      "detail": "Incorrect email passed",
      "code": "bd79c0ab-ddba-46cc-a703-a7a4b08de310"
    }
  ]
}

What are plans on this?

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

3 participants