77use ApacheBorys \Retry \Entity \Message ;
88use ApacheBorys \Retry \Interfaces \Executor ;
99use Psr \Log \LoggerInterface ;
10+ use Throwable ;
1011
1112class CommandExecutor implements Executor
1213{
@@ -75,8 +76,8 @@ public function handle(Message $message): bool
7576 sleep (1 );
7677 }
7778
78- proc_close ($ process );
79- } catch (\ Throwable $ e ) {
79+ $ returnValue = proc_close ($ process );
80+ } catch (Throwable $ e ) {
8081 $ this ->rollbackEnvironmentVariables ();
8182 if ($ this ->logger ) {
8283 $ this ->logger ->debug (
@@ -96,26 +97,30 @@ public function handle(Message $message): bool
9697 return true ;
9798 }
9899
99- public function compilePayload (\ Throwable $ exception , Config $ config ): array
100+ public function compilePayload (Throwable $ exception , Config $ config ): array
100101 {
101102 $ result = [];
102103
103104 foreach ($ this ->arguments as $ argName => $ argRegExp ) {
104- preg_match ($ argRegExp , $ exception ->getMessage (), $ matches );
105- if ($ matches && isset ($ matches [0 ])) {
106- $ result [$ argName ] = $ matches [0 ];
105+ $ matches = [];
106+
107+ try {
108+ preg_match ($ argRegExp , $ exception ->getMessage (), $ matches );
109+ } catch (Throwable $ e ) {
107110 }
111+
112+ $ result [$ argName ] = count ($ matches ) > 0 ? $ matches [0 ] : $ argRegExp ;
108113 }
109114
110115 return $ result ;
111116 }
112117
113- public function getCorrelationId (\ Throwable $ exception , Config $ config ): string
118+ public function getCorrelationId (Throwable $ exception , Config $ config ): string
114119 {
115120 $ id = getenv (self ::ALIAS_FOR_CORRELATION_ID );
116121
117122 if (!$ id ) {
118- $ config ->getTransport ()->getNextId ($ exception , $ config );
123+ $ id = $ config ->getTransport ()->getNextId ($ exception , $ config );
119124 }
120125
121126 return (string ) $ id ;
0 commit comments