Method which generalizes addError() and addFailure()

@throws \InvalidArgumentException
431742
private function doAddFault(Test $test, \Throwable $t, float $time, $type): void
    {
        if ($this->currentTestCase === null) {
            return;
        }

        if ($test instanceof SelfDescribing) {
            $buffer = $test->toString() . "\n";
        } else {
            $buffer = '';
        }

        $buffer .= TestFailure::exceptionToString($t) . "\n" .
            Filter::getFilteredStacktrace($t);

        $fault = $this->document->createElement(
            $type,
            Xml::prepareString($buffer)
        );

        if ($t instanceof ExceptionWrapper) {
            $fault->setAttribute('type', $t->getClassName());
        } else {
            $fault->setAttribute('type', \get_class($t));
        }

        $this->currentTestCase->appendChild($fault);
    }
694030
public function handleRpcErrors($error)
    {
        switch ($error['code']) {
            case -32600:
                throw new \InvalidArgumentException('Invalid Request: '. $error['message']);
            case -32601:
                throw new \BadFunctionCallException('Procedure not found: '. $error['message']);
            case -32602:
                throw new \InvalidArgumentException('Invalid arguments: '. $error['message']);
            case -32603:
                throw new \RuntimeException('Internal Error: '. $error['message']);
            default:
                throw new \RuntimeException('Invalid request/response: '. $error['message'], $error['code']);
        }
    }
29377
protected function _actionFail(KDispatcherContextInterface $context)
    {
        //Check an exception was passed
        if(!isset($context->param) && !$context->param instanceof KException)
        {
            throw new InvalidArgumentException(
                "Action parameter 'exception' [KException] is required"
            );
        }

        //Get the exception object
        if($context->param instanceof KEventException) {
            $exception = $context->param->getException();
        } else {
            $exception = $context->param;
        }

        //If the error code does not correspond to a status message, use 500
        $code = $exception->getCode();
        if(!isset(KHttpResponse::$status_messages[$code])) {
            $code = '500';
        }

        //Get the error message
        $message = KHttpResponse::$status_messages[$code];

        //Set the response status
        $context->response->setStatus($code , $message);

        //Send the response
        $this->send($context);
    }
1083348
private function addMethod(string $method): void
    {
        if (!HttpMethod::isValid($method)) {
            throw new \InvalidArgumentException("Invalid HTTP request method '$method'");
        }

        $this->methods[] = $method;
    }
617230
private static function addBlockErrors(
        iterable $errorsInfo,
        ContextStorageInterface $context,
        ErrorAggregatorInterface $errors
    ): void {
        foreach ($errorsInfo as $errorInfo) {
            $index           = $errorInfo[BlockReplies::ERROR_INFO_BLOCK_INDEX];
            $value           = $errorInfo[BlockReplies::ERROR_INFO_VALUE];
            $errorCode       = $errorInfo[BlockReplies::ERROR_INFO_CODE];
            $messageTemplate = $errorInfo[BlockReplies::ERROR_INFO_MESSAGE_TEMPLATE];
            $messageParams   = $errorInfo[BlockReplies::ERROR_INFO_MESSAGE_PARAMETERS];

            $name = $context->setCurrentBlockId($index)->getProperties()->getProperty(BaseRule::PROPERTY_NAME);

            $errors->add(new Error($name, $value, $errorCode, $messageTemplate, $messageParams));
        }
    }
143007
private function addError($err, $offset = 0)
    {
        $info = $this->source->getDebugInfo($offset);
        $this->sdopx->rethrow($err, $info['line'], $info['src']);
    }
1153196
public function AllErrorToException(){

        if(!class_exists('\\Middlewares\\Whoops'))
            return ;

        set_error_handler(function($severity, $message, $file, $line){
            if (!(error_reporting() & $severity)) {
                // This error code is not included in error_reporting
                return;
            }
            throw new \ErrorException($message, 0, $severity, $file, $line);
        });
    }
751612
public function setErrorHandler()
    {
        set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
            throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
        });
    }
99906
public function addValidationError($errorMessage)
    {
        if (is_string($errorMessage)) {
            $this->validationErrors[] = $errorMessage;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($errorMessage). "' for argument 'errorMessage' given."
            );
        }

        return $this;
    }
1234839
private function appendError()
    {
        $this->errors[(string) curl_errno($this->ch)] = curl_error($this->ch);
    }
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");
        }
    }
979370
public function validateImplementation()
	{
		$required = [
			'model'         => ' does not implement a model definition.',
			'resource_path' => ' does not implement a resource path definition.',
		];

		foreach ($required as $implementation => $message) {
			if (! isset($this->{$implementation})) {
				throw new \InvalidArgumentException(static::class . $message);
			}
		}
	}
1095473
protected function addLoadValidatorMetadataMethod()
    {
        $params = $this->getParameters();
        $constraints = [];

        foreach ($params as $key => $properties) {
            if (!isset($properties['column'])) {
                throw new InvalidArgumentException('Please, define the column to validate.');
            }

            if (!isset($properties['validator'])) {
                throw new InvalidArgumentException('Please, define the validator constraint.');
            }

            if (!class_exists("Symfony\\Component\\Validator\\Constraints\\".$properties['validator'], true)) {
                if (!class_exists("Propel\\Runtime\\Validator\\Constraints\\".$properties['validator'], true)) {
                    throw new ConstraintNotFoundException('The constraint class '.$properties['validator'].' does not exist.');
                } else {
                    $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator'];
                }
            } else {
                $classConstraint = "Symfony\\Component\\Validator\\Constraints\\".$properties['validator'];
            }

            if (isset($properties['options'])) {
                if (!is_array($properties['options'])) {
                    throw new InvalidArgumentException('The options value, in <parameter> tag must be an array');
                }

                $opt = var_export($properties['options'], true);
                $opt = str_replace("\n", '', $opt);
                $opt = str_replace('  ', '', $opt);
                $properties['options'] = $opt;
            }

            $constraints[] = $properties;
            $this->builder->declareClass($classConstraint);
        }

        return $this->renderTemplate('objectLoadValidatorMetadata', ['constraints' => $constraints]);
    }
740280
protected function addError(Exception $e) {
        $errors = $this->getErrors();
        $errors[] = $e;
        $this->setErrors($errors);
    }
1209062
def add_error(key, error, message = nil)
      if error.is_a? Symbol
        error = ErrorAtom.new(key, error, message: message)
      elsif error.is_a?(Mutations::ErrorAtom) || error.is_a?(Mutations::ErrorArray) || error.is_a?(Mutations::ErrorHash)

      else
        raise ArgumentError.new("Invalid error of kind #{error.class}")
      end

      @errors ||= ErrorHash.new
      @errors.tap do |errs|
        path = key.to_s.split(".")
        last = path.pop
        inner = path.inject(errs) do |cur_errors,part|
          cur_errors[part.to_sym] ||= ErrorHash.new
        end
        inner[last] = error
      end
    end
71080
public void addError(String message, int sourceStart, int sourceEnd) {
		ast.addProblem(ast.new ParseProblem(false, message, sourceStart, sourceEnd));
	}
395802
protected function registerErrorHandler()
    {
        $instance = $this;
        $this->previousErrorHandler = set_error_handler(
            function ($errno, $errstr, $errfile, $errline) use ($instance) {
                $message = sprintf('%d: %s - File: %s - Line: %d', $errno, $errstr, $errfile, $errline);
                throw new \Exception($message, $errno);
            }
        );
    }