6
6
7
7
namespace Magento \Framework \Mview \View ;
8
8
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 ;
11
12
use Magento \Framework \Phrase ;
12
13
13
14
/**
14
- * Class Changelog
15
+ * Class Changelog for modifying the mview_state table
15
16
*
16
17
* @package Magento\Framework\Mview\View
17
18
*/
@@ -47,7 +48,10 @@ class Changelog implements ChangelogInterface
47
48
protected $ resource ;
48
49
49
50
/**
51
+ * Changelog constructor
52
+ *
50
53
* @param \Magento\Framework\App\ResourceConnection $resource
54
+ * @throws ConnectionException
51
55
*/
52
56
public function __construct (\Magento \Framework \App \ResourceConnection $ resource )
53
57
{
@@ -60,13 +64,14 @@ public function __construct(\Magento\Framework\App\ResourceConnection $resource)
60
64
* Check DB connection
61
65
*
62
66
* @return void
63
- * @throws \Magento\Framework\Exception\SessionException
67
+ * @throws ConnectionException
64
68
*/
65
69
protected function checkConnection ()
66
70
{
67
71
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
70
75
);
71
76
}
72
77
}
@@ -171,7 +176,7 @@ public function getList($fromVersionId, $toVersionId)
171
176
*
172
177
* @return int
173
178
* @throws ChangelogTableNotExistsException
174
- * @throws LocalizedException
179
+ * @throws RuntimeException
175
180
*/
176
181
public function getVersion ()
177
182
{
@@ -183,8 +188,8 @@ public function getVersion()
183
188
if (isset ($ row ['Auto_increment ' ])) {
184
189
return (int )$ row ['Auto_increment ' ] - 1 ;
185
190
} 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 ] )
188
193
);
189
194
}
190
195
}
@@ -194,14 +199,15 @@ public function getVersion()
194
199
*
195
200
* Build a changelog name by concatenating view identifier and changelog name suffix.
196
201
*
197
- * @throws \Magento\Framework\Exception\LocalizedException
202
+ * @throws DomainException
198
203
* @return string
199
204
*/
200
205
public function getName ()
201
206
{
202
207
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
205
211
);
206
212
}
207
213
return $ this ->viewId . '_ ' . self ::NAME_SUFFIX ;
0 commit comments