adds an error node base on a Exception
@param Exception $error
518656
public function addError(Exception $error)
    {
        $errorNode = $this->addElement("error", $error->getMessage());

        if (!$error instanceof NoRecordsMatchException) {
            $this->status = '400';
        }

        if ($error->getErrorName()) {
            $errorNode->setAttribute("code", $error->getErrorName());
        } else {
            $errorNode->setAttribute("code", "badArgument");
        }
    }
732651
public function caughtException($exception)
    {
        $this->catch_runaway_callbacks = false;

        $l = new \atk4\ui\App();
        $l->initLayout('Centered');

        //check for error type.
        if ($exception instanceof \atk4\core\Exception) {
            $l->layout->template->setHTML('Content', $exception->getHTML());
        } elseif ($exception instanceof \Error) {
            $l->layout->add(['Message', get_class($exception).': '.$exception->getMessage().' (in '.$exception->getFile().':'.$exception->getLine().')', 'error']);
            $l->layout->add(['Text', nl2br($exception->getTraceAsString())]);
        } else {
            $l->layout->add(['Message', get_class($exception).': '.$exception->getMessage(), 'error']);
        }
        $l->layout->template->tryDel('Header');

        if ($this->isJsonRequest()) {
            echo json_encode(['success'   => false,
                                'message' => $l->layout->getHtml(),
                             ]);
        } else {
            $l->catch_runaway_callbacks = false;
            $l->run();
            $this->run_called = true;
        }
        $this->callExit();
    }
1078728
public function wrapAndHandleException($exception)
    {
        if ($exception instanceof Error) {
            $exception = new Exception($exception);
        }

        $this->handleException($exception);
    }
639065
public function setError($error, $key = null)
	{
		if ($error instanceof Exception)
		{
			$this->error = $error;
			return true;
		}

		return false;
	}
732832
public static function handleException($exception)
    {
        static::handleError($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception, true);
    }
917617
public function addFailure(RequestInterface $request, Exception $exception): void
    {
        $this->lastRequest = $request;
        $this->lastException = $exception;
    }
733484
protected function catchError(Exception $exception)
    {
        $exceptionInterpreterService = $this->getServiceLocator()->get(ExceptionInterpreterService::SERVICE_ID);
        $interpretor = $exceptionInterpreterService->getExceptionInterpreter($exception);
        $interpretor->getResponse()->send();
    }
910927
public function setException(\Exception $exception = null)
    {
        $this->exception = $exception;
        $this->result = self::FAILED;
    }
1017676
public function add_node(node $node) {
        $name = $node->name;
        if (isset($this->nodes[$name])) {
            throw new \coding_exception("Node name $name already used");
        }
        $this->nodes[$node->name] = $node;
    }
1285136
public function setError($error)
  {
    if ( !($error instanceof Exception) && is_string($error) ){
      $error = new Exception($error);
    }
    
    array_push($this->errors, $error);
    
    return $this;
  }
446322
public function addError($error)
    {
        $errors = $this->getAttribute('errors') ?: [];

        $errors[] = $error;

        $this->setAttribute('errors', $errors);

        return $this;
    }
945704
public function addException(\Exception $exception)
    {
        if (!$exception instanceof Exception) {
            @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($exception).' will not be possible anymore in the future', E_USER_DEPRECATED);
        }
        $this->exceptions[] = $exception;
    }
1242461
public function add($exception) {
        if($this->checkException($exception) === FALSE) {
            trigger_error(
                'Only subclasses of \Exception and implementations of \Throwable can be aggregated!',
                E_USER_ERROR
            );
        }

        $this->collection[] = $exception;
    }
8608
public function decorateException($error)
    {
        $application = $this->application;

        if (is_callable($error)) {
            $error = $application->getContainer()->call($error, [$application]);
        }

        if (is_object($error) && !($error instanceof \Exception)) {
            $error = method_exists($error,
                '__toString') ? $error->__toString() : 'Error with object ' . get_class($error);
        }

        if (is_resource($error)) {
            $error = 'Error with resource type ' . get_resource_type($error);
        }

        if (is_array($error)) {
            $error = implode("\n", $error);
        }

        if (!($error instanceof \Exception)) {
            $error = new \Exception(is_scalar($error) ? $error : 'Error with ' . gettype($error));
        }

        return $error;
    }
62516
public function normalizeError($error)
    {
        if ($error instanceof \Exception) {
            return new AdaptorException($error->getMessage(), $error->getCode(), $error);
        }

        return new AdaptorException(
            sprintf('An error accord: %s', print_r($error, true)),
            AdaptorException::UNKNOWN_ERROR
        );
    }
606503
public function addError($error)
    {
        if (\is_string($error)) {
            $error = new UserError($error);
        } elseif (!\is_object($error) || !$error instanceof \GraphQL\Error\UserError) {
            throw new \InvalidArgumentException(\sprintf('Error must be string or instance of %s.', \GraphQL\Error\UserError::class));
        }

        $this->errors[] = $error;

        return $this;
    }
501305
public function addError($error)
    {
        if (is_array($error)) {
            $this->errors += $error;
        } else {
            $this->errors[] = $error;
        }

        return $this;
    }