@@ -288,12 +288,44 @@ public function fail($exception): void
288288
289289 $ this ->storedWorkflow ->parents ()
290290 ->each (static function ($ parentWorkflow ) use ($ exception ) {
291- try {
292- $ parentWorkflow ->toWorkflow ()
293- ->fail ($ exception );
294- } catch (TransitionNotFound ) {
291+ if (
292+ $ parentWorkflow ->pivot ->parent_index === StoredWorkflow::CONTINUE_PARENT_INDEX
293+ || $ parentWorkflow ->pivot ->parent_index === StoredWorkflow::ACTIVE_WORKFLOW_INDEX
294+ ) {
295+ try {
296+ $ parentWorkflow ->toWorkflow ()
297+ ->fail ($ exception );
298+ } catch (TransitionNotFound ) {
299+ return ;
300+ }
295301 return ;
296302 }
303+
304+ $ file = new SplFileObject ($ exception ->getFile ());
305+ $ iterator = new LimitIterator ($ file , max (0 , $ exception ->getLine () - 4 ), 7 );
306+
307+ $ throwable = [
308+ 'class ' => get_class ($ exception ),
309+ 'message ' => $ exception ->getMessage (),
310+ 'code ' => $ exception ->getCode (),
311+ 'line ' => $ exception ->getLine (),
312+ 'file ' => $ exception ->getFile (),
313+ 'trace ' => collect ($ exception ->getTrace ())
314+ ->filter (static fn ($ trace ) => Serializer::serializable ($ trace ))
315+ ->toArray (),
316+ 'snippet ' => array_slice (iterator_to_array ($ iterator ), 0 , 7 ),
317+ ];
318+
319+ $ parentWf = $ parentWorkflow ->toWorkflow ();
320+
321+ Exception::dispatch (
322+ $ parentWorkflow ->pivot ->parent_index ,
323+ $ parentWorkflow ->pivot ->parent_now ,
324+ $ parentWorkflow ,
325+ $ throwable ,
326+ $ parentWf ->connection (),
327+ $ parentWf ->queue ()
328+ );
297329 });
298330 }
299331
0 commit comments