Build an exception message from a detailed error array.

@param array $details Error details

@return string
769111
protected function getDateExceptionMessage($details)
    {
        $errors = "Date/time problem: Details: ";
        if (is_array($details['errors']) && $details['error_count'] > 0) {
            foreach ($details['errors'] as $error) {
                $errors .= $error . " ";
            }
        } elseif (is_array($details['warnings'])) {
            foreach ($details['warnings'] as $warning) {
                $errors .= $warning . " ";
            }
        }
        return $errors;
    }
876915
public function columnDetail($detail)
    {
        $columnDetailString = '';

        if (stristr($detail, '(')) {
            $columnDetailString .= $detail;
        } else {
            $columnDetailString .= $detail.'()';
        }

        return $columnDetailString;
    }
590281
protected function filterString($field, $details, $label, $message) {
        if (!(is_string($this->getValue($field)) || is_numeric($this->getValue($field)))) {
            throw new \Exception($message ? $message : $this->translate("$label must be string!"));
        }
        $this->setValue($field, $this->getValue($field) . '');
        if (isset($details['trim']) || in_array('trim', $details)) {
            $this->setValue($field, trim($this->getValue($field)));
        }
        if (isset($details['min']) && strlen($this->getValue($field)) < $details['min']) {
            throw new \Exception($message ? $message : $this->translate("$label must have at least $details[min] characters!"));
        }
        if (isset($details['max']) && strlen($this->getValue($field)) > $details['max']) {
            throw new \Exception($message ? $message : $this->translate("$label must have less than $details[min] characters!"));
        }
        $wordsCount = count(explode(' ', str_replace(array(',', ';', ':', '!', '?', '$', '%', '^', '/', '*', '(', ')', '[', ']', '@', '`', '~', '\'', '\\', '"', '}', '{', "\n"), ' ', $this->getValue($field))));
        if (isset($details['min_words']) && $wordsCount < $details['min_words']) {
            throw new \Exception($message ? $message : $this->translate("$label must have at least $details[min_words] words!"));
        }
        if (isset($details['max_words']) && $wordsCount > $details['max_words']) {
            throw new \Exception($message ? $message : $this->translate("$label must have less than $details[max_words] words!"));
        }
        $lines = count(explode("\n", $this->getValue($field)));
        if (isset($details['min_lines']) && $lines < $details['min_lines']) {
            throw new \Exception($message ? $message : $this->translate("$label must have at least $details[min_lines] lines!"));
        }
        if (isset($details['max_lines']) && $lines > $details['max_lines']) {
            throw new \Exception($message ? $message : $this->translate("$label must have less than $details[max_lines] lines!"));
        }
        return true;
    }
532998
protected function get_error_from_exception($e)
    {
        $data = array();

        if ($e instanceof Crypt_GPG_KeyNotFoundException) {
            $error = enigma_error::KEYNOTFOUND;
            $data['id'] = $e->getKeyId();
        }
        else if ($e instanceof Crypt_GPG_BadPassphraseException) {
            $error = enigma_error::BADPASS;
            $data['bad']     = $e->getBadPassphrases();
            $data['missing'] = $e->getMissingPassphrases();
        }
        else if ($e instanceof Crypt_GPG_NoDataException) {
            $error = enigma_error::NODATA;
        }
        else if ($e instanceof Crypt_GPG_DeletePrivateKeyException) {
            $error = enigma_error::DELKEY;
        }
        else {
            $error = enigma_error::INTERNAL;
        }

        $msg = $e->getMessage();

        return new enigma_error($error, $msg, $data);
    }
1350750
protected function getGeneralErrorMessage(\Exception $caught)
    {
        $singleName = $this->getEntityNameSingular();
        $message = "There was an error when saving {$singleName} data: %s";
        return sprintf($this->translate($message), $caught->getMessage());
    }
869926
public function errors(array $messages): string
    {
        if (!$messages) {
            return ''; // No error messages.
        }
        $messages      = $this->c::markdown($messages, ['no_p' => true]);
        return $markup = '<ul><li>'.implode('</li><li>', $messages).'</li></ul>';
    }
1139038
protected function buildMessage(array $errors)
    {
        $errorList = array();
        foreach ($errors as $error) {
            $errorList[] = sprintf(
                '  - [%s] %s',
                $error['property'],
                $error['message']
            );
        }

        return sprintf(
            "The supplied Composer configuration is invalid:\n%s",
            implode("\n", $errorList)
        );
    }
572542
@JsonIgnore
	public static Message errorMessage(String detailMessage) {
		Message message = new Message();
		message.setDetailMessage(detailMessage);
		message.setSeverity("ERROR");
		message.setType("");
		return message;
	}
539348
private static function _formatTrace($exception)
    {
        $message = '';
        $i = 0;
        $trace = $exception->getTrace();
        array_shift($trace);
        foreach ($trace as $row) {
            $i++;
            $message .= "\n" . '#' . $i;
            $message .= isset($row['file']) ? ' ' . $row['file'] : '';
            $message .= isset($row['line']) ? '(' . $row['line'] . ')' : '';
            $message .= isset($row['class']) ? ' ' . $row['class'] . '::' : '';
            $message .= isset($row['function']) ? (isset($row['class']) ? '' : ' ') . $row['function'] . '(' : '';
            $message .= isset($row['args']) ? json_encode($row['args']) . ')' : '';
        }
        return $message;
    }
131468
protected function displayText(array $details, $verbose = false)
    {
        $errors = 0;

        foreach ($details as $info) {
            if ($info['valid'] && $verbose) {
                $file = ($info['file']) ? ' in '.$info['file'] : '';
                $this->line('<info>OK</info>'.$file);
            } elseif (!$info['valid']) {
                $errors++;
                $this->renderException($info);
            }
        }

        // Output total number of successful files
        $success = count($details) - $errors;
        $total   = count($details);

        $this->comment(sprintf('%d/%d valid files', $success, $total));

        return min($errors, 1);
    }
222166
public function errorMessage()
	{
		if ($this->decoded() === null) {
			throw new \RuntimeException('No result from server.');
		}

		$decoded = $this->decoded();
		if (isset($decoded->error))
			return sprintf('%s (%s)', $decoded->error->message, $decoded->error->code);

		$message = sprintf('%s (%s)', $decoded->message, $this->statusCode());

		if (isset($this->decoded()->errors)) {
			$errors = $this->decoded()->errors;

			$message .= $this->resolveAttributes($errors);
		}

		return $message;
	}
404264
public function getServerVersion($details = false)
    {
        $url = Urls::URL_ADMIN_VERSION;

        if ($details) {
            $url = UrlHelper::appendParamsUrl($url, ['details' => true]);
        }

        $response = $this->getConnection()->get($url);
        $data     = $response->getJson();

        if ($details) {
            return $data;
        }

        return $data['version'];
    }
853004
private function getUrlDestinationDetailsHtml(&$details) {
    $html = '<h4>Url Destination Goal</h4>';
    $html .= <<<HTML
<pre>
Goal URL            = {$details->getUrl()}
Case Sensitive      = {$details->getCaseSensitive()}
Match Type          = {$details->getMatchType()}
First Step Required = {$details->getFirstStepRequired()}
</pre>
HTML;

  $html .= '<h4>Destination Goal Steps</h4>';
  $steps = $details->getSteps();
  if (count($steps) == 0) {
    $html .= '<p>No Steps Configured</p>';

  } else {
    foreach ($steps as &$step) {
      $html .= <<<HTML
<pre>
Step Number = {$step->getNumber()}
Step Name   = {$step->getName()}
Step URL    = {$step->getUrl()}
</pre>
HTML;
    }
  }

  return $html;
  }
80537
protected function _getErrorData()
    {
        $data = [];

        $viewVars = $this->controller->viewVars;
        if (!empty($viewVars['_serialize'])) {
            foreach ($viewVars['_serialize'] as $v) {
                $data[$v] = $viewVars[$v];
            }
        }

        if (!empty($viewVars['error']) && Configure::read('debug')) {
            $data['exception'] = [
                'class' => get_class($viewVars['error']),
                'code' => $viewVars['error']->getCode(),
                'message' => $viewVars['error']->getMessage(),
            ];

            if (!isset($data['trace'])) {
                $data['trace'] = Debugger::formatTrace($viewVars['error']->getTrace(), [
                    'format' => 'array',
                    'args' => false
                ]);
            }
        }

        return $data;
    }
7256
protected function getErrorDetail(array $lines, $at, &$lineNr, &$linePos)
    {
        $totalLength = 0;
        $lineNr      = 0;
        $linePos     = 0;
        $line        = '';

        foreach ($lines as $idx => $line) {
            $length = strlen($line);
            $totalLength += $length;

            if ($totalLength >= $at) {
                $lineNr  = 1 + $idx;
                $linePos = $length - ($totalLength - $at);
                break;
            }
        }

        $content = PHP_EOL . PHP_EOL . '<red>><reset> ' . $line . PHP_EOL
            . ' ' . ($linePos ? str_repeat(' ', $linePos) : '') . '<red>^<reset>' . PHP_EOL;

        return $content;
    }
692034
static protected function formatExceptionMessage(\Exception $exception)
    {

        $errorFullText = '<div><b>New ' . get_class($exception) . '</b></div>';
        $errorFullText .= '<div><b>File:</b> ' . $exception->getFile() . '</div>';
        $errorFullText .= '<div><b>Line:</b> ' . $exception->getLine() . '</div>';
        $errorFullText .= '<div><b>Message:</b> ' . $exception->getMessage() . '</div>';

        $trace = $exception->getTrace();

        if (get_class($exception) != 'DebugException') {
            array_unshift($trace, array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'function' => 'throw ' . get_class($exception), 'args' => array($exception->getMessage(), $exception->getCode())));
        }

        $traceString = '';
        foreach ($trace as $tTraceItem) {

            if (empty ($tTraceItem ['file'])) {
                $tTraceItem ['file'] = '';
            }
            if (empty ($tTraceItem ['line'])) {
                $tTraceItem ['line'] = '';
            }

            $traceString .= '<li>' . basename($tTraceItem ['file']) . " at line #" . $tTraceItem ['line'] . "\t";
            if (isset ($tTraceItem ['class'])) {
                $traceString .= $tTraceItem ['class'] . '::' . $tTraceItem ['function'] . '(';
            } elseif (isset ($tTraceItem ['function'])) {
                $traceString .= $tTraceItem ['function'] . '(';
            }

            if (!empty ($tTraceItem ['args'])) {
                $separator = '';
                foreach ($tTraceItem ['args'] as $arg) {
                    $traceString .= $separator . self::getArgument($arg);
                    $separator = ', ';
                }
                $traceString .= ')';
            }
            $traceString .= "</li>";
        }

        $errorFullText .= '<div><b>Backtrace:</b> <ul style="margin: 0.2em;">' . $traceString . '</ul></div>';

        return $errorFullText;
    }
766148
public function renderFailure($message = '', $code = 10000, $statusCode = 400, $errors = [], $description = '') {
        $data = is_array($message) ? $message : [
            'code' => $code,
            'message' => $message
        ];
        if (!isset($data['code'])) {
            $data['code'] = $code;
        }
        if (!isset($data['message']) && !is_array($message)) {
            $data['message'] = $message;
        }
        if (!empty($errors)) {
            $data['errors'] = $errors;
        }
        if (!empty($description)) {
            $data['description'] = $description;
        }
        return $this->render($data, $statusCode);
    }