When throwing into a catch block, checks that the previous exception is passed to the new throw clause
class SomeClass
{
public function run()
{
try {
$someCode = 1;
} catch (Throwable $throwable) {
- throw new AnotherException('ups');
+ throw new AnotherException('ups', $throwable->getCode(), $throwable);
}
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
ThrowWithPreviousExceptionRector::class,
]);