Skip to content

Commit d1847d1

Browse files
author
Mark Hodge
committed
Update thrown Exceptions to fix static code analysis checks
1 parent e520fa7 commit d1847d1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Framework\Mview\View;
88

9+
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Exception\SessionException;
911
use Magento\Framework\Phrase;
1012

1113
/**
@@ -58,12 +60,14 @@ public function __construct(\Magento\Framework\App\ResourceConnection $resource)
5860
* Check DB connection
5961
*
6062
* @return void
61-
* @throws \Exception
63+
* @throws \Magento\Framework\Exception\SessionException
6264
*/
6365
protected function checkConnection()
6466
{
6567
if (!$this->connection) {
66-
throw new \Exception("The write connection to the database isn't available. Please try again later.");
68+
throw new SessionException(
69+
new Phrase("The write connection to the database isn't available. Please try again later.")
70+
);
6771
}
6872
}
6973

@@ -167,7 +171,7 @@ public function getList($fromVersionId, $toVersionId)
167171
*
168172
* @return int
169173
* @throws ChangelogTableNotExistsException
170-
* @throws \Exception
174+
* @throws LocalizedException
171175
*/
172176
public function getVersion()
173177
{
@@ -179,7 +183,9 @@ public function getVersion()
179183
if (isset($row['Auto_increment'])) {
180184
return (int)$row['Auto_increment'] - 1;
181185
} else {
182-
throw new \Exception("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.");
186+
throw new LocalizedException(
187+
new Phrase("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.")
188+
);
183189
}
184190
}
185191

@@ -188,13 +194,15 @@ public function getVersion()
188194
*
189195
* Build a changelog name by concatenating view identifier and changelog name suffix.
190196
*
191-
* @throws \Exception
197+
* @throws \Magento\Framework\Exception\LocalizedException
192198
* @return string
193199
*/
194200
public function getName()
195201
{
196202
if (strlen($this->viewId) == 0) {
197-
throw new \Exception("View's identifier is not set");
203+
throw new LocalizedException(
204+
new Phrase("View's identifier is not set")
205+
);
198206
}
199207
return $this->viewId . '_' . self::NAME_SUFFIX;
200208
}

0 commit comments

Comments
 (0)