Maps errors to elements children

@param array             $messages
@param ElementCollection $children
422565
protected function mapMessagesToElementCollection(array $messages, ElementCollection $children)
    {
        $children->forAll(function (ElementInterface $element) use ($messages) {
            $this->mapMessagesToElement($messages, $element);
        });
    }
206333
function err(...messages) {
  console.error(...messages);
  const p = document.createElement('p');
  p.innerText = messages.join(' ');
  p.style = 'color: red';
  logElement.appendChild(p);
}
470682
private function mergeErrors($errors)
    {
        if (is_null($errors)) {
            return;
        }

        $errors       = is_array($errors) ? $errors : [$errors];
        $this->errors = array_merge($this->errors, $errors);
    }
691767
protected function showError($title, $messages = '', $output)
    {
        $output->writeln("<error>$title</error>");
        $output->writeln('');
        if (is_array($messages)) {
            foreach ($messages as $message) {
                $output->writeln("<comment>$message</comment>");
            }
            $output->writeln('');
        } elseif ($messages != '') {
            $output->writeln("<comment>$messages</comment>");
            $output->writeln('');
        }
    }
486127
public function writeBeginning($messages = array())
    {
        //Write it for each message = each renderer
        foreach ($messages as $key => $message) {
            $file = $this->outputPath.DIRECTORY_SEPARATOR.$this->rendererFiles[$key].'.html';
            $fileContents = file_get_contents($file);
            file_put_contents($file, $message.$fileContents);
        }
    }
906531
private function setMessageset(array $messages = [])
    {
        // Passed messages rule, but we will use model messages if nothing has been passed
        $this->messageset = $this->selectMessages($messages);

        // If we don't have any rules, don't do anything because an error will never occur
        if ( ! count($this->rules)) return;

        // Determine file for validation messages
        $file = $this->languageFolder . '/' . str_replace('\\', '/', get_called_class()) . '.';

        $this->messages = [];

        // Process each rule
        foreach($this->rules as $field => $set)
        {
            foreach ($set as $rule)
            {
                // Remove parameters if we have them
                list($type,) = $this->getRuleTypeAndParameters($rule);

                // Generate a key using language file dot notation e.g. 'username.required'
                $key = implode('.', [$field, $type]);

                // Try to find a suitable error message
                $message = $this->getMessage($file, $key);
                if ($message) $this->messages[$key] = $message;
            }
        }
    }
842889
public function assertNotMultipleErrors(TableNode $messages)
    {
        $this->assertValidMessageTable($messages, 'error messages');
        foreach ($messages->getHash() as $key => $value) {
            $value = array_change_key_case($value);
            $message = trim($value['error messages']);
            $this->assertNotErrorVisible($message);
        }
    }
707841
private function validateNested(array $errors): array
    {
        foreach ($this->getFields(false) as $index => $value) {
            if (isset($errors[$index])) {
                //Invalid on parent level
                continue;
            }

            if ($value instanceof FilterInterface && !$value->isValid()) {
                $errors[$index] = $value->getErrors();
                continue;
            }

            //Array of nested entities for validation
            if (is_array($value) || $value instanceof \Traversable) {
                foreach ($value as $nIndex => $nValue) {
                    if ($nValue instanceof FilterInterface && !$nValue->isValid()) {
                        $errors[$index][$nIndex] = $nValue->getErrors();
                    }
                }
            }
        }

        return $errors;
    }
133606
private function loopMessage(array &$message, \SimpleXMLElement $xml, array &$errors): array
    {
        // init
        $groupedEdi = [];
        $segmentIdx = 0;

        foreach ($xml->children() as $elm) {
            if ($elm->getName() == "group") {
                $this->processXmlGroup($elm, $message, $segmentIdx, $groupedEdi, $errors);
            } elseif ($elm->getName() == "segment") {
                $this->processXmlSegment($elm, $message, $segmentIdx, $groupedEdi, $errors);
            }
        }

        if ($segmentIdx != \count($message)) {
            $errors[] = [
                "text" => $this->messageTextConf['NOTCONFORMANT'],
            ];
        }

        return ['message' => $groupedEdi, 'errors' => $errors];
    }
897570
public static function createUsingErrors(array $errors)
    {
        $message = "An error was encountered reading an XML document:\n";

        foreach ($errors as $error) {
            switch ($error->level) {
                case LIBXML_ERR_ERROR:
                    $message .= '[Error] ';
                    break;
                case LIBXML_ERR_FATAL:
                    $message .= '[Fatal] ';
                    break;
                case LIBXML_ERR_WARNING:
                    $message .= '[Warning] ';
                    break;
            }

            $message .= sprintf(
                "[line %d] [column %d] %s in \"%s\".\n",
                $error->line,
                $error->column,
                trim($error->message),
                $error->file
            );
        }

        return new self($message);
    }
997705
protected function writeErrorAndDie(array $errors)
    {
        $output = (new ConsoleOutput)->getErrorOutput();

        foreach ($errors as $error) {
            $output->writeln($error);
        }

        die(1);
    }
1335695
public static function withMessages(array $messages)
    {
        return new static(tap(ValidatorFacade::make([], []), function ($validator) use ($messages) {
            foreach ($messages as $key => $value) {
                foreach (Arr::wrap($value) as $message) {
                    $validator->errors()->add($key, $message);
                }
            }
        }));
    }
1028690
private function addError(array & $errors, string $message, array $nodes)
	{
		$errors[] = ['text' => $message, 'nodes' => $nodes];

		$errorGraph = null;
		foreach ($nodes as $node) {
			if ($errorGraph === null) {
				$errorGraph = $node->getGraph();
			} else {
				$nodeGraph = $node->getGraph();
				if ($nodeGraph !== $errorGraph) {
					$errorGraph = $node->getRootGraph();
					break;
				}
			}
		}

		$errorNodeId = '_error_'.md5($message).'_'.count($errors);
		$errorNode = $errorGraph->createNode($errorNodeId, ['label' => $message, 'type' => 'error']);
		foreach ($nodes as $node) {
			$errorGraph->createEdge(null, $errorNode, $node, ['type' => 'error']);
		}
	}
487729
public function setMessages($messages)
    {
        if (!is_array($messages) && !$messages instanceof Traversable) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s expects an array or %s object of messages; received "%s"',
                __METHOD__,
                Traversable::class,
                (is_object($messages) ? get_class($messages) : gettype($messages))
            ));
        }

        foreach ($messages as $key => $messageSet) {
            if (!$this->has($key)) {
                $this->messages[$key] = $messageSet;
                continue;
            }

            $element = $this->get($key);
            $element->setMessages($messageSet);
        }

        return $this;
    }
1240714
protected function fail(
        $message = null,
        $errors = array(),
        array $items = array()
    ) {
        if($message) {
            $_SESSION['flash']['message'] = $message;
            $_SESSION['flash']['type'] = 'danger';
        }

        //if it's a string
        if(is_string($errors)) {
            //redirect will forcefully exit
            return (string) eve()->redirect($errors);
        }

        $this->body['errors'] = $errors;
        $this->body['item'] = $items;

        $this->trigger('html-fail', $this, $message, $errors, $items);
        $this->trigger('response-fail', $this, $message, $errors, $items);

        return $this->build($this->getTemplate());
    }
612928
public function addErrors($param, array $messages)
    {
        foreach ($messages as $message) {
            $this->errors[$param][] = $message;
        }

        return $this;
    }
1035261
protected function renderMessages(array $messages, OutputInterface $output)
    {
        foreach ($messages as $line => $lineErrors) {
            foreach ($lineErrors as $column => $columnErrors) {
                foreach ($columnErrors as $error) {
                    $output->writeln([
                        ">>  $line:$column  <source>" . $error['source'] .
                        '</source>',
                        '    ' . $error['message'],
                    ]);
                }
            }
        }
    }