/** * Converts an exception into an array. * @param \Exception $exception the exception being converted * @return array the array representation of the exception. */ protected function convertExceptionToArray($exception) { if (!YII_DEBUG && !$exception instanceof UserException && !$exception instanceof HttpException) { $exception = new HttpException(500, 'There was an error at the server.'); } $array = ['code' => $exception->getCode(), 'message' => $exception->getMessage()]; if ($exception instanceof LBUserException) { $array['data'] = $exception->getErrors(); } return $array; }