Skip to content

Commit b5e4a00

Browse files
authored
rector: ThrowWithPreviousExceptionRector (#4874)
* rector: `ThrowWithPreviousExceptionRector` - see https://getrector.com/rule-detail/throw-with-previous-exception-rector * fix
1 parent c1d7b61 commit b5e4a00

File tree

18 files changed

+27
-23
lines changed

18 files changed

+27
-23
lines changed

.rector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
->withSkip([
4343
CodeQuality\Assign\CombinedAssignRector::class, # todo: TMP
4444
CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class,
45-
CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class, # todo: TMP
45+
# skip: causes issues with Mage_Api2_Model_Auth_Adapter_Oauth::getUserParams()
46+
CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class => [
47+
__DIR__ . '/app/code/core/Mage/Api2/Model/Auth/Adapter/Oauth.php',
48+
],
4649
CodeQuality\Class_\CompleteDynamicPropertiesRector::class, # todo: TMP (!?!)
4750
CodeQuality\Class_\InlineConstructorDefaultToPropertyRector::class, # todo: TMP
4851
CodeQuality\ClassMethod\ExplicitReturnNullRector::class, # todo: TMP

app/code/core/Mage/Admin/Model/Acl/Role/Registry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addParent($role, $parents)
3131
$role = $this->get($role);
3232
}
3333
} catch (Zend_Acl_Role_Registry_Exception $e) {
34-
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
34+
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist", $e->getCode(), $e);
3535
}
3636

3737
if (!is_array($parents)) {
@@ -46,7 +46,7 @@ public function addParent($role, $parents)
4646
}
4747
$roleParent = $this->get($roleParentId);
4848
} catch (Zend_Acl_Role_Registry_Exception $e) {
49-
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
49+
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", $e->getCode(), $e);
5050
}
5151
$this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
5252
$this->_roles[$roleParentId]['children'][$roleId] = $role;

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Currency/Cron.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function _afterSave()
4141
->setPath(self::CRON_STRING_PATH)
4242
->save();
4343
} catch (Exception $e) {
44-
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
44+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'), $e->getCode(), $e);
4545
}
4646
return $this;
4747
}

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Product/Alert/Cron.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function _afterSave()
4747
->setPath(self::CRON_MODEL_PATH)
4848
->save();
4949
} catch (Exception $e) {
50-
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
50+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'), $e->getCode(), $e);
5151
}
5252
return $this;
5353
}

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Sitemap/Cron.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function _afterSave()
4747
->setPath(self::CRON_MODEL_PATH)
4848
->save();
4949
} catch (Exception $e) {
50-
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
50+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'), $e->getCode(), $e);
5151
}
5252
return $this;
5353
}

app/code/core/Mage/Api/Model/Acl/Role/Registry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addParent($role, $parents)
3131
$role = $this->get($role);
3232
}
3333
} catch (Zend_Acl_Role_Registry_Exception $e) {
34-
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
34+
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist", $e->getCode(), $e);
3535
}
3636

3737
if (!is_array($parents)) {
@@ -46,7 +46,7 @@ public function addParent($role, $parents)
4646
}
4747
$roleParent = $this->get($roleParentId);
4848
} catch (Zend_Acl_Role_Registry_Exception $e) {
49-
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist");
49+
throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", $e->getCode(), $e);
5050
}
5151
$this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
5252
$this->_roles[$roleParentId]['children'][$roleId] = $role;

app/code/core/Mage/Api/Model/Server/Handler/Abstract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function call($sessionId, $apiPath, $args = [])
287287
if ($model instanceof Mage_Api_Model_Resource_Abstract) {
288288
$model->setResourceConfig($resources->$resourceName);
289289
}
290-
} catch (Exception $e) {
290+
} catch (Exception) {
291291
throw new Mage_Api_Exception('resource_path_not_callable');
292292
}
293293

@@ -410,7 +410,7 @@ public function multiCall($sessionId, array $calls = [], $options = [])
410410

411411
try {
412412
$model = Mage::getModel($modelName);
413-
} catch (Exception $e) {
413+
} catch (Exception) {
414414
throw new Mage_Api_Exception('resource_path_not_callable');
415415
}
416416

app/code/core/Mage/Api2/Model/Auth/Adapter/Oauth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Mage_Api2_Model_Auth_Adapter_Oauth extends Mage_Api2_Model_Auth_Adapter_Ab
2020
* Returns stdClass object with two properties: type and id
2121
*
2222
* @return stdClass
23+
* @throws Mage_Api2_Exception
2324
*/
2425
public function getUserParams(Mage_Api2_Model_Request $request)
2526
{

app/code/core/Mage/Api2/Model/Request/Interpreter/Json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function interpret($body)
2929

3030
try {
3131
$decoded = Zend_Json::decode($body);
32-
} catch (Zend_Json_Exception $e) {
32+
} catch (Zend_Json_Exception) {
3333
throw new Mage_Api2_Exception('Decoding error.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
3434
}
3535

app/code/core/Mage/Api2/Model/Resource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ protected function _isSubCallAllowed($resourceId)
827827
try {
828828
return $globalAcl->isAllowed($this->getApiUser(), $resourceId, $this->getOperation());
829829
} catch (Mage_Api2_Exception $e) {
830-
throw new Exception('Invalid arguments for isAllowed() call');
830+
throw new Exception('Invalid arguments for isAllowed() call', $e->getCode(), $e);
831831
}
832832
}
833833

0 commit comments

Comments
 (0)