Skip to content

Commit 3db6746

Browse files
committed
Merge pull request #56 from Remo/curl-exception-handling
handle cURL errors
2 parents 089de23 + 26f99ab commit 3db6746

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Tricks\Exceptions;
4+
5+
use RuntimeException;
6+
7+
class GithubEmailAccessException extends RuntimeException
8+
{
9+
10+
}

app/Tricks/Services/Social/Github.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ protected function getVerifiedEmails($token)
149149

150150
curl_setopt_array($ch, $options);
151151

152-
return json_decode(curl_exec($ch));
152+
$result = curl_exec($ch);
153+
if ($result === false) {
154+
$error = curl_error($ch);
155+
throw new GithubEmailAccessException($error);
156+
}
157+
158+
return json_decode($result);
153159
}
154160
}

0 commit comments

Comments
 (0)