Exemplo n.º 1
0
 /**
  * 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.');
     }
     $errorCode = $exception->getCode();
     $array = ['code' => $errorCode ? $errorCode : 500, 'message' => $exception->getMessage()];
     if ($exception instanceof LBUserException) {
         $array['data'] = $exception->getErrors();
     }
     return $array;
 }