77use ApacheBorys \Retry \Entity \Message ;
88use ApacheBorys \Retry \Interfaces \Executor ;
99use Psr \Log \LoggerInterface ;
10+ use Throwable ;
1011
1112class CommandExecutor implements Executor
1213{
@@ -74,8 +75,8 @@ public function handle(Message $message): bool
7475 sleep (1 );
7576 }
7677
77- proc_close ($ process );
78- } catch (\ Throwable $ e ) {
78+ $ returnValue = proc_close ($ process );
79+ } catch (Throwable $ e ) {
7980 $ this ->rollbackEnvironmentVariables ();
8081 if ($ this ->logger ) {
8182 $ this ->logger ->debug (
@@ -95,26 +96,30 @@ public function handle(Message $message): bool
9596 return true ;
9697 }
9798
98- public function compilePayload (\ Throwable $ exception , Config $ config ): array
99+ public function compilePayload (Throwable $ exception , Config $ config ): array
99100 {
100101 $ result = [];
101102
102103 foreach ($ this ->arguments as $ argName => $ argRegExp ) {
103- preg_match ($ argRegExp , $ exception ->getMessage (), $ matches );
104- if ($ matches && isset ($ matches [0 ])) {
105- $ result [$ argName ] = $ matches [0 ];
104+ $ matches = [];
105+
106+ try {
107+ preg_match ($ argRegExp , $ exception ->getMessage (), $ matches );
108+ } catch (Throwable $ e ) {
106109 }
110+
111+ $ result [$ argName ] = count ($ matches ) > 0 ? $ matches [0 ] : $ argRegExp ;
107112 }
108113
109114 return $ result ;
110115 }
111116
112- public function getCorrelationId (\ Throwable $ exception , Config $ config ): string
117+ public function getCorrelationId (Throwable $ exception , Config $ config ): string
113118 {
114119 $ id = getenv (self ::ALIAS_FOR_CORRELATION_ID );
115120
116121 if (!$ id ) {
117- $ config ->getTransport ()->getNextId ($ exception , $ config );
122+ $ id = $ config ->getTransport ()->getNextId ($ exception , $ config );
118123 }
119124
120125 return (string ) $ id ;
0 commit comments