/**
  * @return array
  */
 public function responseArray()
 {
     $data = parent::responseArray();
     $data['failed_rules'] = $this->getFailedRules();
     return $data;
 }
 /**
  * Creates the error Response associated with the given Exception.
  *
  * @param \Exception|FlattenException $exception An \Exception instance
  *
  * @return Response A Response instance
  */
 public function createResponse($exception)
 {
     $this->jsonResponse['code'] = static::NO_ERROR;
     $this->jsonResponse['type'] = static::TYPE_ERROR;
     if ($exception instanceof ValidationException) {
         $this->jsonResponse['code'] = static::ERROR_VALIDATION;
         $this->jsonResponse['errors'] = $exception->getErrorMessages();
         $this->jsonResponse['failed_rules'] = $exception->getFailedRules();
     } else {
         if ($exception instanceof MissingParameterException) {
             $this->jsonResponse['code'] = static::ERROR_MISSING_PAPAM;
             $this->jsonResponse['fields'] = $exception->getMissedFields();
             $this->jsonResponse['message'] = $exception->getMessage();
         } else {
             if ($exception instanceof AuthenticateException) {
                 $this->jsonResponse['code'] = static::ERROR_UNAUTHORIZED;
                 $this->jsonResponse['message'] = $exception->getMessage();
             } else {
                 if ($exception instanceof ModelNotFoundException) {
                     $this->jsonResponse['code'] = static::ERROR_PAGE_NOT_FOUND;
                     $this->jsonResponse['message'] = $exception->getMessage();
                 } else {
                     if ($exception instanceof MassAssignmentException) {
                         $this->jsonResponse['code'] = static::ERROR_MISSING_ASSIGMENT;
                         $this->jsonResponse['field'] = $exception->getMessage();
                     } else {
                         if ($exception instanceof \Exception) {
                             $this->jsonResponse['code'] = static::ERROR_UNKNOWN;
                             $this->jsonResponse['message'] = $exception->getMessage();
                             if ($this->debug) {
                                 $this->jsonResponse['file'] = $exception->getFile();
                                 $this->jsonResponse['line'] = $exception->getLine();
                             }
                         }
                     }
                 }
             }
         }
     }
     return new JsonResponse($this->jsonResponse, 500, ['Content-Type' => 'application/json']);
 }