/** * Try to detect the generic error message * from the exception object. * * @return string */ public function detectErrorMessage() { $errMessage = 'Internal Server Error'; foreach ($this->exceptionsWithMessages as $e) { if (is_a($this->exception, $e)) { $errMessage = $this->exception->getMessage(); // Symfony2 security component exceptions if (empty($errMessage) && method_exists($this->exception, 'getMessageKey')) { return $this->exception->getMessageKey(); } return $errMessage; } } return $errMessage; }