Updates the error box with the form data, result or error objects

@param \Zepi\Web\UserInterface\Form\Form $form
@param boolean|string $result
@param array $errors
5902
public function updateErrorBox($form, $result, $errors)
    {
        if (($form->isSubmitted() && $result !== true) || count($errors) > 0) {
            if (is_string($result)) {
                $this->addError(new Error(
                    Error::GENERAL_ERROR,
                    $result
                ));
            } else if (count($errors) > 0) {
                foreach ($errors as $error) {
                    $this->addError($error);
                }
            } else {
                $this->addError(new Error(
                    Error::UNKNOWN_ERROR,
                    ''
                ));
            }
        }
    }
1274330
private function formBuilder($view, $errors, $field, $column, $input)
    {
        $formGroupClass = config('form-maker.form.group-class', 'form-group');
        $formErrorClass = config('form-maker.form.error-class', 'has-error');

        $errorHighlight = '';
        $errorMessage = false;

        if (!empty($errors) && $errors->has($column)) {
            $errorHighlight = ' '.$formErrorClass;
            $errorMessage = $errors->get($column);
        }

        if (is_null($view)) {
            $formBuild = '<div class="'.$formGroupClass.' '.$errorHighlight.'">';
            $formBuild .= $this->formContentBuild($field, $column, $input, $errorMessage);
            $formBuild .= '</div>';
        } else {
            $formBuild = View::make($view, [
                'labelFor' => ucfirst($column),
                'label' => $this->columnLabel($field, $column),
                'input' => $input,
                'field' => $field,
                'errorMessage' => $this->errorMessage($errorMessage),
                'errorHighlight' => $errorHighlight,
            ]);
        }

        return $formBuild;
    }
176102
public function prepareError($message, $errors=[], $code=404) {
        $this->prepareResult(false, $message, $code, null , $errors);
    }
590871
public function addErrors(ErrorResourceInterface ...$errors): void
    {
        $this->errors = array_merge($this->errors, $errors);
    }
208195
public function mapErrorsToForm(ConstraintViolationListInterface $errors, FormInterface $form)
    {
        $messages = $this->extractMessages($errors);

        $this->mapMessagesToElementCollection($messages, $form->getChildren());
    }
1255460
public static function validate($form, $errors, $message = '', $style = null) {
		$args = $errors;

		return new JsonView([
			'code'    => self::ERROR,
			'target'  => $form,
			'message' => $message,
			'style'   => $style,
			'args'    => $args,
			'action'  => self::ACT_VALIDATE
		], ['ajax' => '1'], 422);
	}
139013
public function prepareResult($success, $message, $code, $data, $errors) {
        $this->success = $success;
        $this->code = $code;
        $this->message = $message;
        if(is_null($this->data)) {
            $this->data = array();
        } else {
            if(!is_array($this->data)) {
                $old = $this->data;
                $this->data = array();
                array_push($this->data, $old);
            }
        }
        if(!is_null($data)) {
            if(is_array($data)) {
                $this->data = array_merge($this->data, $data);
            } else {
                array_push($this->data, $data);
            }
        }
        if(is_object($this->errors)) {
            $this->errors = Objects::attrToArray($this->errors);
        }
        if(is_string($this->errors) || is_numeric($this->errors)) {
            $err = $this->errors;
            $this->errors = array();
            $this->errors[0] = $err;
        }
        $this->errors = !is_null($errors) ? array_merge($this->errors, $errors) : $this->errors;
    }
1300869
public function finished($success, $results, $operations) {
        if ($success) {
            $message = \Drupal::translation()->formatPlural(count($results), 'One post processed.', '@count posts processed.');
        } else {
            $message = $this->t('Finished with an error.');
        }
        drupal_set_message($message);
    }
469352
public function formHasErrors(FormView $form)
    {
        if ($form->vars['errors']->count()) {
            return true;
        }

        foreach ($form->children as $child) {
            if ($this->formHasErrors($child)) {
                return true;
            }
        }

        return false;
    }
1346742
private function getFormErrors($errors, $formConfig)
    {
        foreach ($errors as $errorKey => $errorValue) {
            foreach ($formConfig['elements'] as $elementKey => $elementValue) {
                if ($elementValue['spec']['name'] == $errorKey && !empty($elementValue['spec']['options']['label'])) {
                    $errors[$elementValue['spec']['options']['label']] = reset($errorValue);
                    unset($errors[$errorKey]);
                }
            }
        }

        return $errors;
    }
579439
protected function setErrors(\Asgard\Validation\Report $errors) {
		foreach($errors->attributes() as $name=>$_errors) {
			if(isset($this->fields[$name]))
				$this->fields[$name]->setErrors($_errors);
		}
	}
839935
public function addError($errorMessage)
    {
        if (is_array($errorMessage)) {
            if (count($errorMessage)) {
                foreach ($errorMessage as $message) {
                    $this->errors[] = $message;
                }
            }
        } else {
            $this->errors[] = $errorMessage;
        }
    }
759899
private function getCommunicationErrorFields(Result $result)
    {
        $fields = array();
        $fields += array(
            'messages' => array(
                'type' => 'markup',
                'label' => $this->t('messages'),
                'value' => $result->getMessages(Result::Format_FormattedText),
            ),
        );
        return $fields;
    }
926020
public function updateRuleFailed(array $errors)
    {
        $url     = handles('antares::ban_management/rules/datatable');
        $message = trans('antares/ban_management::response.rules.update.db-failed', $errors);

        return $this->redirectWithMessage($url, $message, 'error');
    }
295076
protected function processExportResult(& $result, $format)
    {
        if ($format == 'php') {
            $phpResult = json_decode($result, true); // true => return as array instead of object
                
            $jsonError = json_last_error();
                
            switch ($jsonError) {
                case JSON_ERROR_NONE:
                    $result = $phpResult;
                    break;
                default:
                    $message =  "JSON error (" . $jsonError . ") \"" . json_last_error_msg()
                        ."\" in REDCap API output."
                        ."\nThe first 1,000 characters of output returned from REDCap are:\n"
                        .substr($result, 0, 1000);
                    $code = ErrorHandlerInterface::JSON_ERROR;
                    $this->errorHandler->throwException($message, $code);
                    break; // @codeCoverageIgnore
            }
                
            if (array_key_exists('error', $result)) {
                $this->errorHandler->throwException($result ['error'], ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        } else {
            // If this is a format other than 'php', look for a JSON error, because
            // all formats return errors as JSON
            $matches = array();
            $hasMatch = preg_match(self::JSON_RESULT_ERROR_PATTERN, $result, $matches);
            if ($hasMatch === 1) {
                // note: $matches[0] is the complete string that matched
                //       $matches[1] is just the error message part
                $message = $matches[1];
                $this->errorHandler->throwException($message, ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        }
        
        return $result;
    }
249810
public function error(array $errors): Response
    {
        $this->response->setStatus(500);
        $this->response->setBody(json_encode(['errors' => $errors]));
        return $this->response;
    }
195460
public function addValidationError($field, $errorMessage)
    {
        $this->_isValid = false;
        $this->_validationErrors[$field] = $errorMessage;
    }