Skip to content

Commit e43540d

Browse files
committed
Merge pull request googleapis#305 from danielbachhuber/descriptive-error-getresume-uri
Include more description in Exception message when detail is available
2 parents 5044d77 + 90eba3f commit e43540d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Google/Http/MediaFileUpload.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ private function getResumeUri()
287287
if (200 == $code && true == $location) {
288288
return $location;
289289
}
290-
throw new Google_Exception("Failed to start the resumable upload");
290+
$message = $code;
291+
$body = @json_decode( $response->getResponseBody() );
292+
if ( ! empty( $body->error->errors ) ) {
293+
$message .= ': ';
294+
foreach( $body->error->errors as $error ) {
295+
$message .= "{$error->domain}, {$error->message};";
296+
}
297+
$message = rtrim( $message, ';' );
298+
}
299+
throw new Google_Exception("Failed to start the resumable upload (HTTP {$message})");
291300
}
292301
}

0 commit comments

Comments
 (0)