Skip to content

Commit ae74f8b

Browse files
author
Mark Hodge
committed
Update thrown Exceptions to fix static code analysis checks and update PHPDoc Comments
1 parent d1847d1 commit ae74f8b

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
namespace Magento\Framework\Mview\Test\Unit\View;
88

99
/**
10-
* Class ChangelogTest
10+
* Test Changelog View Class
1111
*
12+
* @see \Magento\Framework\Mview\View\Changelog
1213
* @package Magento\Framework\Mview\Test\Unit\View
1314
*/
1415
class ChangelogTest extends \PHPUnit\Framework\TestCase

lib/internal/Magento/Framework/Mview/View/Changelog.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
namespace Magento\Framework\Mview\View;
88

9-
use Magento\Framework\Exception\LocalizedException;
10-
use Magento\Framework\Exception\SessionException;
9+
use DomainException;
10+
use Magento\Framework\DB\Adapter\ConnectionException;
11+
use Magento\Framework\Exception\RuntimeException;
1112
use Magento\Framework\Phrase;
1213

1314
/**
14-
* Class Changelog
15+
* Class Changelog for modifying the mview_state table
1516
*
1617
* @package Magento\Framework\Mview\View
1718
*/
@@ -47,7 +48,10 @@ class Changelog implements ChangelogInterface
4748
protected $resource;
4849

4950
/**
51+
* Changelog constructor
52+
*
5053
* @param \Magento\Framework\App\ResourceConnection $resource
54+
* @throws ConnectionException
5155
*/
5256
public function __construct(\Magento\Framework\App\ResourceConnection $resource)
5357
{
@@ -60,13 +64,14 @@ public function __construct(\Magento\Framework\App\ResourceConnection $resource)
6064
* Check DB connection
6165
*
6266
* @return void
63-
* @throws \Magento\Framework\Exception\SessionException
67+
* @throws ConnectionException
6468
*/
6569
protected function checkConnection()
6670
{
6771
if (!$this->connection) {
68-
throw new SessionException(
69-
new Phrase("The write connection to the database isn't available. Please try again later.")
72+
throw new ConnectionException(
73+
new Phrase("The write connection to the database isn't available. Please try again later."),
74+
E_USER_ERROR
7075
);
7176
}
7277
}
@@ -171,7 +176,7 @@ public function getList($fromVersionId, $toVersionId)
171176
*
172177
* @return int
173178
* @throws ChangelogTableNotExistsException
174-
* @throws LocalizedException
179+
* @throws RuntimeException
175180
*/
176181
public function getVersion()
177182
{
@@ -183,8 +188,8 @@ public function getVersion()
183188
if (isset($row['Auto_increment'])) {
184189
return (int)$row['Auto_increment'] - 1;
185190
} else {
186-
throw new LocalizedException(
187-
new Phrase("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.")
191+
throw new RuntimeException(
192+
new Phrase("Table status for %1 is incorrect. Can`t fetch version id.", [$changelogTableName])
188193
);
189194
}
190195
}
@@ -194,14 +199,15 @@ public function getVersion()
194199
*
195200
* Build a changelog name by concatenating view identifier and changelog name suffix.
196201
*
197-
* @throws \Magento\Framework\Exception\LocalizedException
202+
* @throws DomainException
198203
* @return string
199204
*/
200205
public function getName()
201206
{
202207
if (strlen($this->viewId) == 0) {
203-
throw new LocalizedException(
204-
new Phrase("View's identifier is not set")
208+
throw new DomainException(
209+
new Phrase("View's identifier is not set"),
210+
E_USER_ERROR
205211
);
206212
}
207213
return $this->viewId . '_' . self::NAME_SUFFIX;

0 commit comments

Comments
 (0)