In Magento2, while returning an error from a rest endpoint, i can throw an exception like this
throw new \Magento\Framework\Webapi\Exception(__('No centers matching search criteria'))
It will throw an error like
My requirement, is to add an error code along with response i.e.
{
"message": "No centers matching search criteria.",
"error_code":101
"trace": null
}
Any ideas how this is possible?