Skip to content

Commit 4471bb3

Browse files
authored
Use custom exceptions everywhere (#4)
* Use custom exceptions everywhere * Improve coverage of JsonJobExecutionSerializer
1 parent b36d3c8 commit 4471bb3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/DependencyInjection/YokaiBatchExtension.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
use Symfony\Component\Config\Loader as ConfigLoader;
1010
use Symfony\Component\Console\Application;
1111
use Symfony\Component\DependencyInjection\ContainerBuilder;
12+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1213
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1314
use Symfony\Component\DependencyInjection\Loader as DependencyInjectionLoader;
1415
use Symfony\Component\DependencyInjection\Reference;
1516
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1617
use Symfony\Component\Messenger\MessageBusInterface;
17-
use Symfony\Component\Serializer\SerializerInterface;
18-
use Symfony\Component\Validator\Validator\ValidatorInterface;
1918
use Yokai\Batch\Bridge\Doctrine\DBAL\DoctrineDBALJobExecutionStorage;
2019
use Yokai\Batch\Launcher\JobLauncherInterface;
2120
use Yokai\Batch\Storage\FilesystemJobExecutionStorage;
@@ -114,7 +113,7 @@ private function configureStorage(ContainerBuilder $container, array $config): v
114113
try {
115114
$defaultStorageDefinition = $container->getDefinition($defaultStorage);
116115
} catch (ServiceNotFoundException $exception) {
117-
throw new \LogicException(
116+
throw new LogicException(
118117
sprintf('Configured default job execution storage service "%s" does not exists.', $defaultStorage),
119118
0,
120119
$exception
@@ -130,7 +129,14 @@ private function configureStorage(ContainerBuilder $container, array $config): v
130129
foreach ($interfaces as $interface => $required) {
131130
if (!is_a($defaultStorageClass, $interface, true)) {
132131
if ($required) {
133-
throw new \LogicException();//todo
132+
throw new LogicException(
133+
\sprintf(
134+
'Job execution storage service "%s", is of class "%s", and must implements interface "%s".',
135+
$defaultStorage,
136+
$defaultStorageClass,
137+
$interface
138+
)
139+
);
134140
}
135141
continue;
136142
}

0 commit comments

Comments
 (0)