Collapse a nested error into a standard Result object.
@param array $errors The nested error set.
@return Result The unnested Result object.
517659
protected static function unnest(NestableResult $struct) : Result
    {
        $result = $struct->outer();

        foreach ($struct as $key => $error) {
            if ($error instanceof NestableResult) {
                $error = self::unnest($error);
            }

            $result = $result->concat(
                $error->map(function ($e) use ($key) {
                    return $key . ': ' . $e;
                })
            );
        }

        return $result;
    }
1361718
public function getError($error, $opts=array()) {
		if (is_array($error) && isset($error['filter'])) {
			return $this->getErrorMessage($error['filter'], $error+$opts);
		} elseif (is_int($error)) {
			return $this->getErrorMessage($error, $opts);
		} else {
			return $this->getErrorMessage(0, $opts);
		}
	}
590942
public static function mailErrorToAdmin(ArrayObject $errors) {
        $errorMessage = self::_composeFullErrorMessage($errors);
        $subjectPrefix = '';
        if (isset($_SERVER) && !empty($_SERVER['HTTP_HOST'])) {
            $subjectPrefix = '[' . $_SERVER['HTTP_HOST'] . '] ';
        }

        $ini = Zend_Registry::get('config');
        $to = (
            isset($ini->app) &&
            isset($ini->app->errorReportEmailAddress) &&
            $ini->app->errorReportEmailAddress
        )
            ? $ini->app->errorReportEmailAddress
            : self::ERROR_REPORT_MAIL_ADDRESS_FALLBACK
        ;

        $mailer = new Garp_Mailer();
        return $mailer->send(
            array(
            'to' => $to,
            'subject' => $subjectPrefix . 'An application error occurred',
            'message' => $errorMessage
            )
        );
    }
304410
public function addError($error)
    {
        if ($error instanceof self) {
            $this->errors = array_merge($this->errors, $error->errors);
        } else {
            $this->errors[] = $error;
        }

        return $this;
    }
123987
public function addErrors(array $errors)
    {
        foreach ($errors as $error) {
            if (!$error instanceof ValidationError)
                throw new Exception('Error was not instance of ValidationError: '.$error);
            if (!in_array($error, $this->errors))
                $this->errors[] = $error;
        }

        return $this;
    }
1281663
protected function errors(array $errors): array
    {
        $final = [];
        foreach ($errors as $errorId => $details) {
            if ($details instanceOf ParamError) {
                $final[$errorId] = $details;
            } else {
                $final[$errorId] = ParamError::fromData($errorId, $details);
            }
        }

        return [null, $final];
    }
137810
private function extractErrors($error)
    {
        $messages = [];

        foreach ($error as $key => $errors)
        {
            // If error is a MessageBag, extract errors
            if ($errors instanceof MessageBag) return $this->extractErrors($errors->toArray());

            // If we have an array of errors preserve key
            if (is_array($errors))
            {
                $messages[$key] = $this->extractErrors($errors);
                continue;
            }

            // We must be down to a single error, just return it
            return $errors;
        }

        return $messages;
    }
1178952
private function pluckError(array $error) {
        $row = array_intersect_key(
            $error,
            ['field' => 1, 'error' => 1, 'code' => 1]
        );

        $row['message'] = $this->formatErrorMessage($error);
        return $row;
    }
151276
protected function formatFailure($result)
    {
        $appConfig = $this->di->get('config')['application'];
        $inflector = $this->di->get('inflector');

        $result->errors = [];

        //for each errorStore, build one or more error objects
        foreach ($this->errors as $error) {

            //if this error includes a list of validation issues, map them into error objects and concat the result
            if ($error->validationList) {
                $validationErrors = array_map(function (Message $validation) use ($error, $appConfig, $inflector) {
                    $field = $inflector->normalize($validation->getField(), $appConfig['propertyFormatTo']);
                    $details = [
                        'code' => $error->code,
                        'title' => $error->title,
                        'detail' => $validation->getMessage(),
                        'source' => ['pointer' => "/data/attributes/$field"],
                        'meta' => ['field' => $field]
                    ];
                    if ($appConfig['debugApp'] && $error->dev) {
                        $details['meta']['developer_message'] = $error->dev;
                    }
                    return $details;
                }, $error->validationList);

                $result->errors = array_merge($result->errors, $validationErrors);

                //however, if it's a plain error, concat an error object with some additional trace information
            } else {
                $details = [
                    'title' => $error->title,
                    'code' => $error->code,
                    'detail' => $error->more,
                ];

                //it doesn't make much sense to add stacktrace info to validation errors, right?
                if ($appConfig['debugApp']) {
                    $meta = array_filter([ //clears up empty keys
                        'developer_message' => $error->dev,
                        'file' => $error->file,
                        'line' => $error->line,
                        'stack' => $error->stack,
                        'context' => $error->context,
                    ]);

                    if ($meta) {
                        $details['meta'] = $meta;
                    }
                }

                $result->errors[] = $details;
            }
        }
    }
904692
public static function fatal(string $error) : Result
    {
        $result = new self([$error]);
        $result->fatal = true;

        return $result;
    }
650214
public function errors($nested=true) {
		$errors = $this->rules;
		foreach($this->attributes as $attribute=>$report)
			$errors[$attribute] = $nested ? $report->errors():$report->error();
		return $errors;
	}
658894
public static function createFailure($message, $errors = array()) {
	    $report = new static(self::TYPE_ERROR, $message);
	    foreach ($errors as $error) {
	        $report->add($error);
	    }
	    return $report;
	}
258645
public function apiErrorResponse($errors, $inputs)
    {
        $message = [];
        foreach ($inputs as $key => $value) {
            if (!isset($errors[$key])) {
                $message[$key] = [
                    'status' => 'valid',
                    'value' => $value,
                ];
            } else {
                $message[$key] = [
                    'status' => 'invalid',
                    'error' => $errors[$key],
                    'value' => $value,
                ];
            }
        }

        return Response::json(['status' => 'error', 'data' => $message]);
    }
470682
private function mergeErrors($errors)
    {
        if (is_null($errors)) {
            return;
        }

        $errors       = is_array($errors) ? $errors : [$errors];
        $this->errors = array_merge($this->errors, $errors);
    }
1048344
protected function log_error($errors) {
        if (empty($errors)) {
            return;
        }

        foreach ($errors as $code => $langstring) {
            if (!isset($this->errors[$this->linenb])) {
                $this->errors[$this->linenb] = array();
            }
            $this->errors[$this->linenb][$code] = $langstring;
        }
    }
756921
protected function showErrors($errors)
    {
        $i = 0;
        $this->output->writeln("\nThere was ".count($errors).' errors:');

        foreach ($errors as $filename => $error) {
            $this->output->writeln('<comment>'.++$i.". {$filename}:{$error['line']}".'</comment>');

            $this->output->write($this->getHighlightedCodeSnippet($filename, $error['line']));

            $this->output->writeln("<error> {$error['error']}</error>");
        }
    }
1127813
public function ignoreOrderErrors(
        array $errors = [
            ['entity_id' => null, 'error_category_code' => null, 'error_code' => null]
        ]
    ) {
        /** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
        $responseHandler = $this->service()->patch($this->baseUrlPath('orders'));
        return $responseHandler;
    }