Skip to content

Commit 5718f4b

Browse files
Merge pull request #38 from wp-cli/35-catch-exception
Make use of 'halt_on_error' to catch error and release lock
2 parents e3ae26e + 60b5f3b commit 5718f4b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/WP_CLI/CoreUpgrader.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ public function download_package( $package ) {
6666
*/
6767
$headers = array( 'Accept' => 'application/json' );
6868
$options = array(
69-
'timeout' => 600, // 10 minutes ought to be enough for everybody.
70-
'filename' => $temp
69+
'timeout' => 600, // 10 minutes ought to be enough for everybody.
70+
'filename' => $temp,
71+
'halt_on_error' => false,
7172
);
7273

7374
$this->skin->feedback( 'downloading_package', $package );
7475

7576
/** @var \Requests_Response|null $req */
76-
$req = Utils\http_request( 'GET', $package, null, $headers, $options );
77+
try {
78+
$req = Utils\http_request( 'GET', $package, null, $headers, $options );
79+
} catch( \Exception $e ) {
80+
return new \WP_Error( 'download_failed', $e->getMessage() );
81+
}
7782
if ( ! is_null( $req ) && $req->status_code !== 200 ) {
7883
return new \WP_Error( 'download_failed', $this->strings['download_failed'] );
7984
}

0 commit comments

Comments
 (0)