10
10
use Magento \Framework \Module \ModuleList ;
11
11
use Magento \Framework \ObjectManagerInterface ;
12
12
use Magento \Framework \Phrase ;
13
- use Magento \Framework \Setup \Exception ;
13
+ use Magento \Framework \Setup \Exception as SetupException ;
14
14
use Magento \Framework \Setup \ModuleDataSetupInterface ;
15
15
16
16
/**
@@ -129,8 +129,8 @@ public function __construct(
129
129
/**
130
130
* Apply all patches for one module
131
131
*
132
- * @param null | string $moduleName
133
- * @throws Exception
132
+ * @param null| string $moduleName
133
+ * @throws SetupException
134
134
*/
135
135
public function applyDataPatch ($ moduleName = null )
136
136
{
@@ -149,7 +149,7 @@ public function applyDataPatch($moduleName = null)
149
149
['moduleDataSetup ' => $ this ->moduleDataSetup ]
150
150
);
151
151
if (!$ dataPatch instanceof DataPatchInterface) {
152
- throw new Exception (
152
+ throw new SetupException (
153
153
new Phrase ("Patch %1 should implement DataPatchInterface " , [get_class ($ dataPatch )])
154
154
);
155
155
}
@@ -164,7 +164,17 @@ public function applyDataPatch($moduleName = null)
164
164
$ this ->moduleDataSetup ->getConnection ()->commit ();
165
165
} catch (\Exception $ e ) {
166
166
$ this ->moduleDataSetup ->getConnection ()->rollBack ();
167
- throw new Exception (new Phrase ($ e ->getMessage ()));
167
+ throw new SetupException (
168
+ new Phrase (
169
+ 'Unable to apply data patch %1 for module %2. Original exception message: %3 ' ,
170
+ [
171
+ get_class ($ dataPatch ),
172
+ $ moduleName ,
173
+ $ e ->getMessage ()
174
+ ]
175
+ ),
176
+ $ e
177
+ );
168
178
} finally {
169
179
unset($ dataPatch );
170
180
}
@@ -173,8 +183,7 @@ public function applyDataPatch($moduleName = null)
173
183
}
174
184
175
185
/**
176
- * Register all patches in registry in order to manipulate chains and dependencies of patches
177
- * of patches
186
+ * Register all patches in registry in order to manipulate chains and dependencies of patches of patches
178
187
*
179
188
* @param string $moduleName
180
189
* @param string $patchType
@@ -207,8 +216,8 @@ private function prepareRegistry($moduleName, $patchType)
207
216
*
208
217
* Please note: that schema patches are not revertable
209
218
*
210
- * @param null | string $moduleName
211
- * @throws Exception
219
+ * @param null| string $moduleName
220
+ * @throws SetupException
212
221
*/
213
222
public function applySchemaPatch ($ moduleName = null )
214
223
{
@@ -229,7 +238,7 @@ public function applySchemaPatch($moduleName = null)
229
238
$ schemaPatch ->apply ();
230
239
$ this ->patchHistory ->fixPatch (get_class ($ schemaPatch ));
231
240
} catch (\Exception $ e ) {
232
- throw new Exception (
241
+ throw new SetupException (
233
242
new Phrase (
234
243
'Unable to apply patch %1 for module %2. Original exception message: %3 ' ,
235
244
[
@@ -248,8 +257,8 @@ public function applySchemaPatch($moduleName = null)
248
257
/**
249
258
* Revert data patches for specific module
250
259
*
251
- * @param null | string $moduleName
252
- * @throws Exception
260
+ * @param null| string $moduleName
261
+ * @throws SetupException
253
262
*/
254
263
public function revertDataPatches ($ moduleName = null )
255
264
{
@@ -270,7 +279,7 @@ public function revertDataPatches($moduleName = null)
270
279
$ adapter ->commit ();
271
280
} catch (\Exception $ e ) {
272
281
$ adapter ->rollBack ();
273
- throw new Exception (new Phrase ($ e ->getMessage ()));
282
+ throw new SetupException (new Phrase ($ e ->getMessage ()));
274
283
} finally {
275
284
unset($ dataPatch );
276
285
}
0 commit comments