Skip to content

Commit b79a323

Browse files
Fix exception messages containing exception messages
1 parent bd952b9 commit b79a323

File tree

13 files changed

+14
-14
lines changed

13 files changed

+14
-14
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function locate($template, $currentPath = null, $first = true)
7979
try {
8080
return $this->cacheHits[$key] = $this->locator->locate($template->getPath(), $currentPath);
8181
} catch (\InvalidArgumentException $e) {
82-
throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e);
82+
throw new \InvalidArgumentException(sprintf('Unable to find template "%s": ', $template).$e->getMessage(), 0, $e);
8383
}
8484
}
8585
}

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static function createConnection($dsn, array $options = [])
120120
try {
121121
@$redis->{$connect}($params['host'], $params['port'], $params['timeout'], $params['persistent_id'], $params['retry_interval']);
122122
} catch (\RedisException $e) {
123-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
123+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
124124
}
125125

126126
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ final public function finalize($value)
335335
} catch (Exception $e) {
336336
throw $e;
337337
} catch (\Exception $e) {
338-
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": '.$e->getMessage(), $this->getPath()), $e->getCode(), $e);
338+
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e);
339339
}
340340
}
341341

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ protected function getConstructor(Definition $definition, $required)
126126
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
127127
}
128128
} catch (\ReflectionException $e) {
129-
throw new RuntimeException(sprintf('Invalid service "%s": '.lcfirst($e->getMessage()), $this->currentId));
129+
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
130130
}
131131
if (!$r = $r->getConstructor()) {
132132
if ($required) {
133133
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
134134
}
135135
} elseif (!$r->isPublic()) {
136-
throw new RuntimeException(sprintf('Invalid service "%s": %s must be public.', $this->currentId, sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class)));
136+
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
137137
}
138138

139139
return $r;

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private function parseFileToDOM($file)
378378
try {
379379
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
380380
} catch (\InvalidArgumentException $e) {
381-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": "%s".', $file, $e->getMessage()), $e->getCode(), $e);
381+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": ', $file).$e->getMessage(), $e->getCode(), $e);
382382
}
383383

384384
$this->validateExtensions($dom, $file);

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ protected function loadFile($file)
660660
try {
661661
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
662662
} catch (ParseException $e) {
663-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $file).': '.$e->getMessage(), 0, $e);
663+
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $file).$e->getMessage(), 0, $e);
664664
} finally {
665665
restore_error_handler();
666666
}

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getController(Request $request)
8888
try {
8989
$callable = $this->createController($controller);
9090
} catch (\InvalidArgumentException $e) {
91-
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e);
91+
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
9292
}
9393

9494
return $callable;

src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function load($file, $type = null)
6666
try {
6767
$parsedConfig = $this->yamlParser->parseFile($path);
6868
} catch (ParseException $e) {
69-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
69+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);
7070
} finally {
7171
restore_error_handler();
7272
}

src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function handle(GetResponseEvent $event)
100100
try {
101101
$this->tokenStorage->setToken($this->attemptSwitchUser($request, $username));
102102
} catch (AuthenticationException $e) {
103-
throw new \LogicException(sprintf('Switch User failed: "%s".', $e->getMessage()));
103+
throw new \LogicException('Switch User failed: '.$e->getMessage());
104104
}
105105
}
106106

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function extract($resource, MessageCatalogue $catalogue, $domain)
5353
try {
5454
$dom = XmlUtils::loadFile($resource);
5555
} catch (\InvalidArgumentException $e) {
56-
throw new InvalidResourceException(sprintf('Unable to load "%s": '.$e->getMessage(), $resource), $e->getCode(), $e);
56+
throw new InvalidResourceException(sprintf('Unable to load "%s": ', $resource).$e->getMessage(), $e->getCode(), $e);
5757
}
5858

5959
$xliffVersion = $this->getVersionNumber($dom);

0 commit comments

Comments
 (0)