Skip to content

Commit fed9906

Browse files
committed
minor #538 Adds a point at the end of exception messages (GromNaN)
This PR was merged into the 3.x branch. Discussion ---------- Adds a point at the end of exception messages | Q | A | ------------- | --- | Branch? | 3.x | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Please Fabbot. https://github.com/symfony/monolog-bundle/actions/runs/18049106453/job/51366974230?pr=537 Commits ------- f0ba2b0 Adds a point at the end of exception messages
2 parents cf375b7 + f0ba2b0 commit fed9906

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

src/DependencyInjection/Compiler/AddProcessorsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function process(ContainerBuilder $container)
3838

3939
foreach ($tags as $tag) {
4040
if (!empty($tag['channel']) && !empty($tag['handler'])) {
41-
throw new \InvalidArgumentException(\sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s"', $id));
41+
throw new \InvalidArgumentException(\sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s".', $id));
4242
}
4343

4444
if (!empty($tag['handler'])) {
@@ -49,7 +49,7 @@ public function process(ContainerBuilder $container)
4949
}
5050
$class = $container->getParameterBag()->resolveValue($parentDef->getClass());
5151
if (!method_exists($class, 'pushProcessor')) {
52-
throw new \InvalidArgumentException(\sprintf('The "%s" handler does not accept processors', $tag['handler']));
52+
throw new \InvalidArgumentException(\sprintf('The "%s" handler does not accept processors.', $tag['handler']));
5353
}
5454
} elseif (!empty($tag['channel'])) {
5555
if ('app' === $tag['channel']) {

src/DependencyInjection/Compiler/LoggerChannelPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ public function process(ContainerBuilder $container)
9797
try {
9898
$logger = $container->getDefinition('app' === $channel ? 'monolog.logger' : 'monolog.logger.'.$channel);
9999
} catch (InvalidArgumentException $e) {
100-
$msg = 'Monolog configuration error: The logging channel "'.$channel.'" assigned to the "'.substr($handler, 16).'" handler does not exist.';
101-
throw new \InvalidArgumentException($msg, 0, $e);
100+
throw new \InvalidArgumentException(\sprintf('Monolog configuration error: The logging channel "%s" assigned to the "%s" handler does not exist.', $channel, substr($handler, 16)), 0, $e);
102101
}
103102
$logger->addMethodCall('pushHandler', [new Reference($handler)]);
104103
}

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ public function getConfigTreeBuilder(): TreeBuilder
777777
->then(function ($v) {
778778
$invalidTags = preg_grep('/^[a-z0-9][a-z0-9\.\-_]*$/i', $v['tags'], \PREG_GREP_INVERT);
779779
if (!empty($invalidTags)) {
780-
throw new InvalidConfigurationException(\sprintf('The following Loggly tags are invalid: %s.', implode(', ', $invalidTags)));
780+
throw new InvalidConfigurationException(\sprintf('The following Loggly tags are invalid: "%s".', implode('", "', $invalidTags)));
781781
}
782782

783783
return $v;
@@ -1124,7 +1124,7 @@ private function addChannelsSection(ArrayNodeDefinition $handlerNode)
11241124
$isExclusive = true;
11251125
} else {
11261126
if (true === $isExclusive) {
1127-
throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list');
1127+
throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list.');
11281128
}
11291129
$elements[] = $element;
11301130
$isExclusive = false;

src/DependencyInjection/MonologExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
233233

234234
$publisher->setPublic(false);
235235
} else {
236-
throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed');
236+
throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed.');
237237
}
238238

239239
$definition->setArguments([
@@ -330,7 +330,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
330330

331331
case 'telegram':
332332
if (!class_exists('Monolog\Handler\TelegramBotHandler')) {
333-
throw new \RuntimeException('The TelegramBotHandler is not available. Please update "monolog/monolog" to 2.2.0');
333+
throw new \RuntimeException('The TelegramBotHandler is not available. Please update "monolog/monolog" to 2.2.0.');
334334
}
335335

336336
$definition->setArguments([
@@ -916,7 +916,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
916916
$nullWarning = ', if you meant to define a null handler in a yaml config, make sure you quote "null" so it does not get converted to a php null';
917917
}
918918

919-
throw new \InvalidArgumentException(\sprintf('Invalid handler type "%s" given for handler "%s"'.$nullWarning, $handler['type'], $name));
919+
throw new \InvalidArgumentException(\sprintf('Invalid handler type "%s" given for handler "%s".'.$nullWarning, $handler['type'], $name));
920920
}
921921

922922
if (!empty($handler['nested']) && true === $handler['nested']) {

tests/DependencyInjection/MonologExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ public function testLogglyHandler()
527527
]]]]);
528528
$this->fail();
529529
} catch (InvalidConfigurationException $e) {
530-
$this->assertStringContainsString('-us, apache$', $e->getMessage());
530+
$this->assertSame('The following Loggly tags are invalid: "-us", "apache$".', $e->getMessage());
531531
}
532532

533533
$container = $this->getContainer([['handlers' => ['loggly' => [

0 commit comments

Comments
 (0)