/** * Send response to the client, render exceptions if they are present. * * @return void */ public function sendResponse() { try { if ($this->isException()) { $this->_renderMessages(); } parent::sendResponse(); } catch (\Exception $e) { if ($e instanceof \Magento\Webapi\Exception) { // If the server does not support all MIME types accepted by the client it SHOULD send 406. $httpCode = $e->getHttpCode() == \Magento\Webapi\Exception::HTTP_NOT_ACCEPTABLE ? \Magento\Webapi\Exception::HTTP_NOT_ACCEPTABLE : \Magento\Webapi\Exception::HTTP_INTERNAL_ERROR; } else { $httpCode = \Magento\Webapi\Exception::HTTP_INTERNAL_ERROR; } /** If error was encountered during "error rendering" process then use error renderer. */ $this->_errorProcessor->renderException($e, $httpCode); } }