@@ -142,7 +142,14 @@ public function apply($id)
142142 );
143143 }
144144
145- $ pull = $ github ->pulls ->get ($ this ->getState ()->get ('github_user ' ), $ this ->getState ()->get ('github_repo ' ), $ id );
145+ try
146+ {
147+ $ pull = $ github ->pulls ->get ($ this ->getState ()->get ('github_user ' ), $ this ->getState ()->get ('github_repo ' ), $ id );
148+ }
149+ catch (\Exception $ e )
150+ {
151+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB ' , $ e ->getMessage ()));
152+ }
146153
147154 if (is_null ($ pull ->head ->repo ))
148155 {
@@ -164,7 +171,14 @@ public function apply($id)
164171
165172 $ transport = new \JHttp ($ options , $ driver );
166173
167- $ patch = $ transport ->get ($ pull ->diff_url )->body ;
174+ try
175+ {
176+ $ patch = $ transport ->get ($ pull ->diff_url )->body ;
177+ }
178+ catch (\Exception $ e )
179+ {
180+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB ' , $ e ->getMessage ()));
181+ }
168182
169183 $ files = $ this ->parsePatch ($ patch );
170184
@@ -177,26 +191,33 @@ public function apply($id)
177191 {
178192 if ($ file ->action == 'deleted ' && !file_exists (JPATH_ROOT . '/ ' . $ file ->old ))
179193 {
180- throw new \RuntimeException (sprintf ( \JText::_ ('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S ' ) , $ file ->old ));
194+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S ' , $ file ->old ));
181195 }
182196
183197 if ($ file ->action == 'added ' || $ file ->action == 'modified ' )
184198 {
185199 // If the backup file already exists, we can't apply the patch
186200 if (file_exists (JPATH_COMPONENT . '/backups/ ' . md5 ($ file ->new ) . '.txt ' ))
187201 {
188- throw new \RuntimeException (sprintf ( \JText::_ ('COM_PATCHTESTER_CONFLICT_S ' ) , $ file ->new ));
202+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_CONFLICT_S ' , $ file ->new ));
189203 }
190204
191205 if ($ file ->action == 'modified ' && !file_exists (JPATH_ROOT . '/ ' . $ file ->old ))
192206 {
193- throw new \RuntimeException (sprintf ( \JText::_ ('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S ' ) , $ file ->old ));
207+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S ' , $ file ->old ));
194208 }
195209
196210 $ url = 'https://raw.github.com/ ' . urlencode ($ pull ->head ->user ->login ) . '/ ' . urlencode ($ pull ->head ->repo ->name )
197211 . '/ ' . urlencode ($ pull ->head ->ref ) . '/ ' . $ file ->new ;
198212
199- $ file ->body = $ transport ->get ($ url )->body ;
213+ try
214+ {
215+ $ file ->body = $ transport ->get ($ url )->body ;
216+ }
217+ catch (\Exception $ e )
218+ {
219+ throw new \RuntimeException (\JText::sprintf ('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB ' , $ e ->getMessage ()));
220+ }
200221 }
201222 }
202223
0 commit comments