@@ -176,17 +176,7 @@ public function doExecute(StepExecution $stepExecution)
176
176
continue ;
177
177
}
178
178
} catch (InvalidItemException $ e ) {
179
- $ stepExecution ->addError (
180
- get_class ($ this ->reader ),
181
- $ e ->getMessage (),
182
- $ e ->getItem ()
183
- );
184
-
185
- $ this ->dispatchInvalidItemEvent (
186
- get_class ($ this ->reader ),
187
- $ e ->getMessage (),
188
- $ e ->getItem ()
189
- );
179
+ $ this ->handleStepExecutionWarning ($ stepExecution , get_class ($ this ->reader ), $ e );
190
180
191
181
continue ;
192
182
}
@@ -203,17 +193,7 @@ public function doExecute(StepExecution $stepExecution)
203
193
);
204
194
}
205
195
} catch (InvalidItemException $ e ) {
206
- $ stepExecution ->addError (
207
- get_class ($ this ->processor ),
208
- $ e ->getMessage (),
209
- $ e ->getItem ()
210
- );
211
-
212
- $ this ->dispatchInvalidItemEvent (
213
- get_class ($ this ->processor ),
214
- $ e ->getMessage (),
215
- $ e ->getItem ()
216
- );
196
+ $ this ->handleStepExecutionWarning ($ stepExecution , get_class ($ this ->processor ), $ e );
217
197
218
198
continue ;
219
199
}
@@ -225,17 +205,7 @@ public function doExecute(StepExecution $stepExecution)
225
205
$ this ->writer ->write ($ itemsToWrite );
226
206
$ itemsToWrite = array ();
227
207
} catch (InvalidItemException $ e ) {
228
- $ stepExecution ->addError (
229
- get_class ($ this ->writer ),
230
- $ e ->getMessage (),
231
- $ e ->getItem ()
232
- );
233
-
234
- $ this ->dispatchInvalidItemEvent (
235
- get_class ($ this ->processor ),
236
- $ e ->getMessage (),
237
- $ e ->getItem ()
238
- );
208
+ $ this ->handleStepExecutionWarning ($ stepExecution , get_class ($ this ->writer ), $ e );
239
209
240
210
continue ;
241
211
}
@@ -247,17 +217,7 @@ public function doExecute(StepExecution $stepExecution)
247
217
$ this ->writer ->write ($ itemsToWrite );
248
218
$ itemsToWrite = array ();
249
219
} catch (InvalidItemException $ e ) {
250
- $ stepExecution ->addError (
251
- get_class ($ this ->writer ),
252
- $ e ->getMessage (),
253
- $ e ->getItem ()
254
- );
255
-
256
- $ this ->dispatchInvalidItemEvent (
257
- get_class ($ this ->processor ),
258
- $ e ->getMessage (),
259
- $ e ->getItem ()
260
- );
220
+ $ this ->handleStepExecutionWarning ($ stepExecution , get_class ($ this ->writer ), $ e );
261
221
}
262
222
}
263
223
}
@@ -279,4 +239,17 @@ protected function initializeStepComponents(StepExecution $stepExecution)
279
239
$ this ->writer ->setStepExecution ($ stepExecution );
280
240
}
281
241
}
242
+
243
+ /**
244
+ * Handle step execution warning
245
+ *
246
+ * @param StepExecution $stepExecution
247
+ * @param string $class
248
+ * @param InvalidItemException $e
249
+ */
250
+ private function handleStepExecutionWarning (StepExecution $ stepExecution , $ class , InvalidItemException $ e )
251
+ {
252
+ $ stepExecution ->addError ($ class , $ e ->getMessage (), $ e ->getItem ());
253
+ $ this ->dispatchInvalidItemEvent ($ class , $ e ->getMessage (), $ e ->getItem ());
254
+ }
282
255
}
0 commit comments