Skip to content

Commit 6d77eb4

Browse files
committed
Emit run.finish even if exception is thrown
1 parent 80079cb commit 6d77eb4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ExerciseDispatcher.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@ public function run(ExerciseInterface $exercise, $fileName, OutputInterface $out
175175
{
176176
$this->eventDispatcher->dispatch(new Event('run.start', compact('exercise', 'fileName')));
177177

178-
$exitStatus = $this->runnerFactory
179-
->create($exercise, $this->eventDispatcher)
180-
->run($fileName, $output);
178+
try {
179+
$exitStatus = $this->runnerFactory
180+
->create($exercise, $this->eventDispatcher)
181+
->run($fileName, $output);
182+
} finally {
183+
$this->eventDispatcher->dispatch(new Event('run.finish', compact('exercise', 'fileName')));
184+
}
181185

182-
$this->eventDispatcher->dispatch(new Event('run.finish', compact('exercise', 'fileName')));
183186
return $exitStatus;
184187
}
185188

0 commit comments

Comments
 (0)