@@ -86,15 +86,18 @@ public function creationTimeOfOldestPendingJob($queue = null)
8686 */
8787 public function push ($ job , $ data = '' , $ queue = null )
8888 {
89+ $ lastException = null ;
90+
8991 foreach ($ this ->connections as $ connection ) {
9092 try {
9193 return $ this ->manager ->connection ($ connection )->push ($ job , $ data , $ queue );
9294 } catch (Throwable $ e ) {
95+ $ lastException = $ e ;
9396 $ this ->events ->dispatch (new QueueFailedOver ($ connection , $ job ));
9497 }
9598 }
9699
97- throw $ e ;
100+ throw $ lastException ?? new \ RuntimeException ( ' No available connections to push the job. ' ) ;
98101 }
99102
100103 /**
@@ -106,15 +109,17 @@ public function push($job, $data = '', $queue = null)
106109 */
107110 public function pushRaw ($ payload , $ queue = null , array $ options = [])
108111 {
112+ $ lastException = null ;
113+
109114 foreach ($ this ->connections as $ connection ) {
110115 try {
111116 return $ this ->manager ->connection ($ connection )->pushRaw ($ payload , $ queue , $ options );
112117 } catch (Throwable $ e ) {
113- //
118+ $ lastException = $ e ;
114119 }
115120 }
116121
117- throw $ e ;
122+ throw $ lastException ?? new \ RuntimeException ( ' No available connections to push the raw payload. ' ) ;
118123 }
119124
120125 /**
@@ -128,15 +133,18 @@ public function pushRaw($payload, $queue = null, array $options = [])
128133 */
129134 public function later ($ delay , $ job , $ data = '' , $ queue = null )
130135 {
136+ $ lastException = null ;
137+
131138 foreach ($ this ->connections as $ connection ) {
132139 try {
133140 return $ this ->manager ->connection ($ connection )->later ($ delay , $ job , $ data , $ queue );
134141 } catch (Throwable $ e ) {
142+ $ lastException = $ e ;
135143 $ this ->events ->dispatch (new QueueFailedOver ($ connection , $ job ));
136144 }
137145 }
138146
139- throw $ e ;
147+ throw $ lastException ?? new \ RuntimeException ( ' No available connections to schedule the job. ' ) ;
140148 }
141149
142150 /**
0 commit comments