Do not use this method. It will be removed in 2.0.

@param ParamInterface                   $parameter
@param ConstraintViolationListInterface $violations
@param string                           $message

@return self

@internal
187389
public static function withViolationsAndMessage(ParamInterface $parameter, ConstraintViolationListInterface $violations, $message)
    {
        $exception = new self($message);
        $exception->parameter = $parameter;
        $exception->violations = $violations;

        return $exception;
    }
102116
private function buildMessage(ConstraintViolationListInterface $violations)
    {
        $msg = '';
        $errors = [];
        $childrenErrors = [];

        /* @var ConstraintViolationInterface $violation */
        foreach ($violations as $violation) {
            if (null === $violation->getPropertyPath()) {
                $errors[] = $violation->getMessage();
            } else {
                $childrenErrors[$violation->getPropertyPath()][] = $violation->getMessage();
            }
        }

        $msg = $this->buildGlobalErrors($errors, $msg);
        $msg = $this->buildChildrenErrors($childrenErrors, $msg);

        return $msg;
    }
895003
public function consumeOne(MessageInterface $message)
    {
        $consumeEvent = new ConsumeEvent($message);

        try {
            $this->dispatcher->dispatch(BarbeQEvents::PRE_CONSUME, $consumeEvent);

            $message->start();

            $this->messageDispatcher->dispatch($message->getQueue(), $consumeEvent);

            $message->complete();
            $this->adapter->onSuccess($message);

            $this->dispatcher->dispatch(BarbeQEvents::POST_CONSUME, $consumeEvent);
        } catch(\Exception $e) {
            $message->completeWithError();
            $this->adapter->onError($message);

            $this->dispatcher->dispatch(BarbeQEvents::POST_CONSUME, $consumeEvent);

            // TODO
            throw new ConsumerIndigestionException("Error while consuming a message", 0, $e);
        }
    }
109770
public function set_message($rule, $message)
	{
		if ($message !== null)
		{
			$this->error_messages[$rule] = $message;
		}
		else
		{
			unset($this->error_messages[$rule]);
		}

		return $this;
	}
868464
public function withMessage(string $message): PayloadInterface
    {
        if ($this->message === $message) {
            return $this;
        }

        $clone = clone $this;
        $clone->message = $message;

        return $clone;
    }
684439
public function message(string $message)
    {
        $this->_validations[\count($this->_validations) - 1]['message'] = $message;

        return $this;
    }
882501
public function validateConstraints(array $constraints, Parameter $parameter)
  {
    try
    {
      $violationList = $this->validator->validate(
        $parameter->getValue(),
        $constraints
      );
    }
    catch (\Exception $e)
    {
      $this->dispatcher->dispatch(TransformerEvents::ON_EXCEPTION, new ExceptionEvent($e));
      $violationList = $this->handleException($e, $parameter);
    }

    if ($violationList->count() > 0)
    {
      $invalidValue = $violationList->get(0)->getInvalidValue();
      if (is_array($invalidValue))
      {
        $invalidValue = '[' . implode(', ', $invalidValue) . ']';
      }
      throw new TransformerException(
        'Key: ' . $parameter->getKey() . ' - ' . 'Value: '
        . $invalidValue . ' - Error: '
        . $violationList->get(0)->getMessage()
      );
    }
  }
529705
public static function withErrorCodeAndParams($errorCode, $message, $parameters, $innerException = null)
	{
		// The messages use the .NET string substitution convention using curly braces
		// so these few lines replace references with the appropriate parameter
		if ( preg_match_all( "/\{(\d)\}/", $message, $matches ) )
		{
			foreach ( $matches[1] as $index => $match )
			{
				if ( ! isset( $parameters[$match] ) ) continue;
				$message = str_replace( "{{$match}}", $parameters[$match], $message );
			}
		}

		$ex = new XPath2Exception( $message, $innerException );
		$ex->ErrorCode = $errorCode;
		return $ex;
	}
732037
public function setDefaultMessage(string $rule, string $message): self
    {
        $this->defaultMessages[$rule] = $message;

        return $this;
    }
32824
private function createMessage(ConstraintViolationListInterface $list, $line)
    {
        $messages = [];
        foreach ($list as $violation) {
            $messages[] = $violation->getMessage();
        }

        return sprintf('Line %d: %s', $line, implode(', ', $messages));
    }
950340
public function setMessage($message)
    {
        if ( ! is_null($message)) $message = (string) $message;

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

        return $this;
    }
124578
public function message($message)
    {
        if (is_string($message) || is_numeric($message)) {
            $message = new Text($message);
        }

        if (!($message instanceof Message)) {
            throw new InvalidArgumentException('Invalid message.');
        }

        $this->message = $message;

        return $this;
    }
1262248
protected function dispatchConsumerTimingEvent($intervalMs, MessageInterface $message)
    {
        $event = new TimingEvent(TimingEvent::CONSUMER_TIMING);
        $event->setIntervalMs($intervalMs);
        $event->setMessage($message);

        if (null !== ($dispatcher = $this->getEventDispatcher())) {
            $dispatcher->dispatch(TimingEvent::CONSUMER_TIMING, $event);
        }
    }
613429
protected function createViolation($value, Constraint $constraint)
    {
        $this
            ->context
            ->buildViolation($constraint->message)
            ->setParameter('%filename%', $value)
            ->addViolation();
    }
505595
protected function addViolation($error, Constraint $constraint)
    {
        $this->context->buildViolation($constraint->message)
            ->setParameter('%error%', $error)
            ->addViolation()
        ;

        return true;
    }
181141
public function addInstanceRule(string $name, callable $callback, string $message = null): self
    {
        static::assertRuleCallback($callback);

        $this->_instanceRules[$name] = $callback;
        $this->_instanceRuleMessage[$name] = $message;

        return $this;
    }
431821
public function addValidator($index, $method = null, array $params = [], $message = null)
    {
        // set up params
        array_unshift($params, $method);
        array_unshift($params, $index);

        call_user_func_array([$this->getValidator(), 'addRule'], $params);

        // Message management
        if (!is_null($message)) {
            $this->getValidator()->addMessage($index, $message);
        }

        return $this;
    }