Symfony 4 — A good way to deal with exceptions for REST API

Photo by Nate Grant on Unsplash
{
"message": "",
"data": [],
"errors": {}
}
{
"message": "Invalid form",
"data": {},
"errors": {
"email": [
"This is not a valid email"
]
}
}

Handle exceptions

Normalize form exceptions

Normalizer factory

Full-stack Developer & Security Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store