Skip to content

Commit a606d6d

Browse files
committed
Throw custom MutexRuntimeException
1 parent afb023a commit a606d6d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/MutexRuntimeException.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Illuminated\Console;
4+
5+
use RuntimeException;
6+
7+
class MutexRuntimeException extends RuntimeException
8+
{
9+
}

src/WithoutOverlapping.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Illuminated\Console;
44

5-
use RuntimeException;
65
use Symfony\Component\Console\Input\InputInterface;
76
use Symfony\Component\Console\Output\OutputInterface;
87

@@ -19,15 +18,15 @@ protected function initializeMutex()
1918
{
2019
$mutex = new Mutex($this);
2120
if (!$mutex->acquireLock($this->getMutexTimeout())) {
22-
throw new RuntimeException('Command is running now!');
21+
throw new MutexRuntimeException('Command is running now!');
2322
}
2423

2524
register_shutdown_function([$this, 'releaseMutexLock'], $mutex);
2625
}
2726

2827
public function getMutexStrategy()
2928
{
30-
return (property_exists($this, 'mutexStrategy') ? $this->mutexStrategy : 'file');
29+
return property_exists($this, 'mutexStrategy') ? $this->mutexStrategy : 'file';
3130
}
3231

3332
public function setMutexStrategy($strategy)
@@ -37,7 +36,7 @@ public function setMutexStrategy($strategy)
3736

3837
public function getMutexTimeout()
3938
{
40-
return (property_exists($this, 'mutexTimeout') ? $this->mutexTimeout : 0);
39+
return property_exists($this, 'mutexTimeout') ? $this->mutexTimeout : 0;
4140
}
4241

4342
public function setMutexTimeout($timeout)

0 commit comments

Comments
 (0)