add custom error and force error message in template

@param string $errorName
@param mixed $errorNameIndex
@param string message

@return HtmlForm
177771
public function setError($errorName, $errorNameIndex = null, $message = null) {

		if(is_null($errorNameIndex)) {
			$this->formErrors[$errorName] = new FormError($message);
		}
		else {
			$this->formErrors[$errorName][$errorNameIndex] = new FormError($message);
		}

		return $this;

	}
748314
private function reportError(string $errorId = null)
    {
        $reportError = $this->reportError;
        $reportError((null === $errorId) ? ($this->defaultErrorId) : ($errorId));
    }
722951
private function createQueryError(string $paramName, string $errorTitle): ErrorInterface
    {
        $source = [ErrorInterface::SOURCE_PARAMETER => $paramName];
        $error  = new JsonApiError(null, null, null, null, null, $errorTitle, null, $source);

        return $error;
    }
199302
public static function make($errorCode, $errorMessage)
    {
        $exception = Arr::get(self::$supported, $errorCode, Errors\Error::class);

        return new $exception($errorMessage, $errorCode);
    }
456350
public function appendError($error_key, $error_string)
	{
		if($this->getErrors())
		{
			// append
			$this->errors->add( $error_key, $error_string );
		}
		else
		{
			// new MessageBag
			$this->errors = new MessageBag( array($error_key => $error_string) );
		}
	}
114965
public static function requiredError($attributeName, $annotationName, $context, $expected)
    {
        return self::typeError(sprintf(
            'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
            $attributeName,
            $annotationName,
            $context,
            $expected
        ));
    }
721252
public function setErrorTemplate($errorTemplate, $engine = null)
    {
        if (!\is_string($errorTemplate)) {
            throw new \InvalidArgumentException('Please use string as template name (Example: "folder.file").');
        }

        $this->errorTemplate = $errorTemplate;

        if ($engine) {
            $this->setEngine($engine);
        }
    }
1193166
public function declareError(string $pointcutExpression, string $message, int $errorLevel = E_USER_ERROR): void
    {
        $interceptor = new DeclareErrorInterceptor($message, $errorLevel, $pointcutExpression);
        $this->registerAdviceInContainer($pointcutExpression, $interceptor);
    }
349035
public function createErrorView($errorMessage, $exception, $displayExceptions = false, $displayNavMenu = false )
    {
      $viewModel = new ViewModel(array(
          'navMenu' => $displayNavMenu,
          'display_exceptions' => $displayExceptions,
          'errorMessage' => $errorMessage,
          'exception' => $exception,
      ));
      $viewModel->setTemplate('csn-user/error/error');
      return $viewModel;
    }
364412
public function setError($name, $error)
    {
        if (!$this->getInputFilter() instanceof ErrorMessageInterface) {
            throw new NotSupportedException(sprintf(
                'Method %s::%s() is not supported.',
                get_class($this->getInputFilter()),
                __FUNCTION__
            ));
        }
        $this->getInputFilter()->setMessage($name, $error);
        return $this;
    }
800978
protected function addError($name, $customMessage = null)
    {
        $this->errors[$name] = $customMessage ?: $this->message ?: $this->{$name . 'Message'};
    }
339731
protected function SetRequired($name, $errorPrefix = '')
    {
        $field = $this->GetElement($name);
        if (!$field instanceof FormField)
        {
            throw new \InvalidArgumentException("$name is not a field in the form elements");
        }
        if (!$errorPrefix)
        {
            $errorPrefix = $this->ErrorPrefix($name);
        }
        $field->SetRequired($errorPrefix);
    }
662630
protected function throwNewInvalidArgumentException ($errorMsg) {
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		$str = '['.$selfClass.'] ' . $errorMsg . ' ('
			. 'form id: `'.$this->id . '`, '
			. 'form type: `'.get_class($this->form).'`'
		.')';
		throw new \InvalidArgumentException($str);
	}
526190
static public function errorHandler($errorNumber, $errorString, $errorFile, $errorLine)
    {

        /*
         * Is line has been suppressed with an @, do not throw an exception
         */
        if (error_reporting() == 0) {
            return;
        }

        $errorFullText = self::formatErrorText($errorNumber, $errorString, $errorFile, $errorLine);

        /*
     * Hold execution
     */
        if (self::$errorHoldsExecution) {
            throw new DebugException ($errorFullText, $errorNumber);
        } else {
            /*
     * display error
     */
            if (self::$displayErrors) {
                echo self::displayBox();
            }
            /*
       * Message error
       */
            if (self::$displayTrace) {
                echo self::formatError($errorFullText);
            }

            /*
     * Send message do psHelpdesk
     */
            if (self::$sendTrace) {
                self::send($errorFullText);
            }
        }

    }
1022572
public function register($name, $class, $errorMessage = '', $labeledErrorMessage = '')
    {
        if (is_subclass_of($class, '\Sirius\Validation\Rule\AbstractRule')) {
            $this->validatorsMap[$name] = $class;
        }
        if ($errorMessage) {
            $this->errorMessages[$name] = $errorMessage;
        }
        if ($labeledErrorMessage) {
            $this->labeledErrorMessages[$name] = $labeledErrorMessage;
        }

        return $this;
    }
1276539
private function build_message( array $input_data = [ ], $error_template ) {

		if ( ! substr_count( $error_template, '%' ) ) {
			return $error_template;
		}

		array_key_exists( 'value', $input_data ) or $input_data[ 'value' ] = NULL;

		// replacing the placeholder for the %value%
		$message = str_replace( '%value%', $this->as_string( $input_data[ 'value' ] ), $error_template );
		unset( $input_data[ 'value' ] );

		// replacing the placeholder for the %key%
		$data_key = isset( $input_data[ 'key' ] ) ? $input_data[ 'key' ] : '';
		array_key_exists( $data_key, $this->key_labels ) and $data_key = $this->key_labels[ $data_key ];
		$message = str_replace( '%key%', $this->as_string( $data_key ), $message );
		unset( $input_data[ 'key' ] );

		// replacing the possible options-placeholder on the message
		foreach ( $input_data as $key => $replace ) {
			is_numeric( $key ) or $message = str_replace( '%' . $key . '%', $this->as_string( $replace ), $message );
		}

		return $message;

	}
519074
protected static function displayError($errorMessage, $displayHelp = false, $exit = true)
    {
        echo "\n  " . self::red() . 'Error: ' . self::resetColor() . $errorMessage . "\n";
        if ($displayHelp) {
            self::helpAction();
        } else {
            echo "\n";
        }
        if ($exit) {
            exit(1);
        }
    }