Merge branch '4.4' into 5.0
* 4.4: Fix exception messages containing exception messages
This commit is contained in:
commit
992f50fee2
@ -45,7 +45,7 @@ class CachePoolsTest extends AbstractWebTestCase
|
|||||||
}
|
}
|
||||||
$this->markTestSkipped($e->getMessage());
|
$this->markTestSkipped($e->getMessage());
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
if (0 !== strpos($e->getMessage(), 'Redis connection failed')) {
|
if (0 !== strpos($e->getMessage(), 'Redis connection ')) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->markTestSkipped($e->getMessage());
|
$this->markTestSkipped($e->getMessage());
|
||||||
|
@ -107,6 +107,6 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
|
|||||||
|
|
||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']);
|
$tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']);
|
||||||
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass (public)', $tester->getDisplay());
|
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
|
|||||||
public function testFailedCreateConnection(string $dsn)
|
public function testFailedCreateConnection(string $dsn)
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('Redis connection failed');
|
$this->expectExceptionMessage('Redis connection ');
|
||||||
RedisAdapter::createConnection($dsn);
|
RedisAdapter::createConnection($dsn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
|||||||
public function testFailedCreateConnection(string $dsn)
|
public function testFailedCreateConnection(string $dsn)
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('Redis connection failed');
|
$this->expectExceptionMessage('Redis connection ');
|
||||||
RedisAdapter::createConnection($dsn);
|
RedisAdapter::createConnection($dsn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ trait RedisTrait
|
|||||||
try {
|
try {
|
||||||
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
|
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
|
||||||
} catch (\RedisException $e) {
|
} catch (\RedisException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||||
@ -182,7 +182,7 @@ trait RedisTrait
|
|||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!$isConnected) {
|
if (!$isConnected) {
|
||||||
$error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : '';
|
$error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : '';
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed%s: "%s".', $error, $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$error.'.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((null !== $auth && !$redis->auth($auth))
|
if ((null !== $auth && !$redis->auth($auth))
|
||||||
@ -190,7 +190,7 @@ trait RedisTrait
|
|||||||
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
|
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
|
||||||
) {
|
) {
|
||||||
$e = preg_replace('/^ERR /', '', $redis->getLastError());
|
$e = preg_replace('/^ERR /', '', $redis->getLastError());
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e, $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e.'.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
||||||
@ -215,7 +215,7 @@ trait RedisTrait
|
|||||||
try {
|
try {
|
||||||
$redis = new $class($hosts, $params);
|
$redis = new $class($hosts, $params);
|
||||||
} catch (\RedisClusterException $e) {
|
} catch (\RedisClusterException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
||||||
@ -230,7 +230,7 @@ trait RedisTrait
|
|||||||
try {
|
try {
|
||||||
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
|
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
|
||||||
} catch (\RedisClusterException $e) {
|
} catch (\RedisClusterException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
|
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
|
||||||
|
@ -422,7 +422,7 @@ abstract class BaseNode implements NodeInterface
|
|||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": '.$e->getMessage(), $this->getPath()), $e->getCode(), $e);
|
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,14 +150,14 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
|||||||
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
||||||
}
|
}
|
||||||
} catch (\ReflectionException $e) {
|
} catch (\ReflectionException $e) {
|
||||||
throw new RuntimeException(sprintf('Invalid service "%s": '.lcfirst($e->getMessage()), $this->currentId));
|
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
|
||||||
}
|
}
|
||||||
if (!$r = $r->getConstructor()) {
|
if (!$r = $r->getConstructor()) {
|
||||||
if ($required) {
|
if ($required) {
|
||||||
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
|
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
|
||||||
}
|
}
|
||||||
} elseif (!$r->isPublic()) {
|
} elseif (!$r->isPublic()) {
|
||||||
throw new RuntimeException(sprintf('Invalid service "%s": %s must be public.', $this->currentId, sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class)));
|
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -395,7 +395,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
|
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": "%s".', $file, $e->getMessage()), $e->getCode(), $e);
|
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": ', $file).$e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validateExtensions($dom, $file);
|
$this->validateExtensions($dom, $file);
|
||||||
|
@ -682,7 +682,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
|
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $file).': '.$e->getMessage(), 0, $e);
|
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $file).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->validate($configuration, $file);
|
return $this->validate($configuration, $file);
|
||||||
|
@ -96,7 +96,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
|||||||
try {
|
try {
|
||||||
$options = $this->getOptionsResolver()->resolve($options);
|
$options = $this->getOptionsResolver()->resolve($options);
|
||||||
} catch (ExceptionInterface $e) {
|
} catch (ExceptionInterface $e) {
|
||||||
throw new $e(sprintf('An error has occurred resolving the options of the form "%s": '.$e->getMessage(), \get_class($this->getInnerType())), $e->getCode(), $e);
|
throw new $e(sprintf('An error has occurred resolving the options of the form "%s": ', \get_class($this->getInnerType())).$e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should be decoupled from the specific option at some point
|
// Should be decoupled from the specific option at some point
|
||||||
|
@ -153,11 +153,11 @@ trait ResponseTrait
|
|||||||
try {
|
try {
|
||||||
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
|
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
|
||||||
} catch (\JsonException $e) {
|
} catch (\JsonException $e) {
|
||||||
throw new JsonException(sprintf($e->getMessage().' for "%s".', $this->getInfo('url')), $e->getCode());
|
throw new JsonException($e->getMessage().sprintf(' for "%s".', $this->getInfo('url')), $e->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error()) {
|
if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error()) {
|
||||||
throw new JsonException(sprintf(json_last_error_msg().' for "%s".', $this->getInfo('url')), json_last_error());
|
throw new JsonException(json_last_error_msg().sprintf(' for "%s".', $this->getInfo('url')), json_last_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_array($content)) {
|
if (!\is_array($content)) {
|
||||||
|
@ -85,7 +85,7 @@ class ControllerResolver implements ControllerResolverInterface
|
|||||||
try {
|
try {
|
||||||
$callable = $this->createController($controller);
|
$callable = $this->createController($controller);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e);
|
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_callable($callable)) {
|
if (!\is_callable($callable)) {
|
||||||
|
@ -31,7 +31,7 @@ abstract class AbstractApiTransport extends AbstractHttpTransport
|
|||||||
try {
|
try {
|
||||||
$email = MessageConverter::toEmail($message->getOriginalMessage());
|
$email = MessageConverter::toEmail($message->getOriginalMessage());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: '.$e->getMessage(), __CLASS__), 0, $e);
|
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->doSendApi($message, $email, $message->getEnvelope());
|
return $this->doSendApi($message, $email, $message->getEnvelope());
|
||||||
|
@ -113,7 +113,7 @@ class ConnectionTest extends TestCase
|
|||||||
public function testFailedAuth()
|
public function testFailedAuth()
|
||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Redis connection failed');
|
$this->expectExceptionMessage('Redis connection ');
|
||||||
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
|
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
|
||||||
|
|
||||||
$redis->expects($this->exactly(1))->method('auth')
|
$redis->expects($this->exactly(1))->method('auth')
|
||||||
|
@ -62,7 +62,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
|
$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
|
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = new RouteCollection();
|
$collection = new RouteCollection();
|
||||||
|
@ -332,7 +332,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
|
|||||||
try {
|
try {
|
||||||
$this->setAttributeValue($object, $attribute, $value, $format, $context);
|
$this->setAttributeValue($object, $attribute, $value, $format, $context);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": '.$e->getMessage(), $attribute, $type), $e->getCode(), $e);
|
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": ', $attribute, $type).$e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class XliffFileLoader implements LoaderInterface
|
|||||||
try {
|
try {
|
||||||
$dom = XmlUtils::loadFile($resource);
|
$dom = XmlUtils::loadFile($resource);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new InvalidResourceException(sprintf('Unable to load "%s": '.$e->getMessage(), $resource), $e->getCode(), $e);
|
throw new InvalidResourceException(sprintf('Unable to load "%s": ', $resource).$e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$xliffVersion = XliffUtils::getVersionNumber($dom);
|
$xliffVersion = XliffUtils::getVersionNumber($dom);
|
||||||
|
@ -42,7 +42,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT);
|
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML', $resource).': '.$e->getMessage(), 0, $e);
|
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML: ', $resource).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $messages && !\is_array($messages)) {
|
if (null !== $messages && !\is_array($messages)) {
|
||||||
|
@ -55,7 +55,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator
|
|||||||
try {
|
try {
|
||||||
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
|
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
|
||||||
} catch (NoSuchPropertyException $e) {
|
} catch (NoSuchPropertyException $e) {
|
||||||
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $path, \get_class($constraint)), 0, $e);
|
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $path, \get_class($constraint)).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$comparedValue = $constraint->value;
|
$comparedValue = $constraint->value;
|
||||||
|
@ -130,7 +130,7 @@ class BicValidator extends ConstraintValidator
|
|||||||
try {
|
try {
|
||||||
$iban = $this->getPropertyAccessor()->getValue($object, $path);
|
$iban = $this->getPropertyAccessor()->getValue($object, $path);
|
||||||
} catch (NoSuchPropertyException $e) {
|
} catch (NoSuchPropertyException $e) {
|
||||||
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $path, \get_class($constraint)), 0, $e);
|
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $path, \get_class($constraint)).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$iban) {
|
if (!$iban) {
|
||||||
|
@ -157,7 +157,7 @@ class RangeValidator extends ConstraintValidator
|
|||||||
try {
|
try {
|
||||||
return $this->getPropertyAccessor()->getValue($object, $propertyPath);
|
return $this->getPropertyAccessor()->getValue($object, $propertyPath);
|
||||||
} catch (NoSuchPropertyException $e) {
|
} catch (NoSuchPropertyException $e) {
|
||||||
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $propertyPath, \get_class($constraint)), 0, $e);
|
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $propertyPath, \get_class($constraint)).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
|
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
|
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// empty file
|
// empty file
|
||||||
|
Reference in New Issue
Block a user