Skip to content

Commit f359ab8

Browse files
committed
Merge pull request #29 from jamesggordon/add-error-codes-to-exceptions
Where available, add error codes to exceptions
2 parents 781a941 + b5c2bd3 commit f359ab8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Madcoda/Youtube.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public function decodeSingle(&$apiData)
393393
if (isset($resObj->error->errors[0])) {
394394
$msg .= " : " . $resObj->error->errors[0]->reason;
395395
}
396-
throw new \Exception($msg);
396+
throw new \Exception($msg,$resObj->error->code);
397397
} else {
398398
$itemsArray = $resObj->items;
399399
if (!is_array($itemsArray) || count($itemsArray) == 0) {
@@ -419,7 +419,7 @@ public function decodeList(&$apiData)
419419
if (isset($resObj->error->errors[0])) {
420420
$msg .= " : " . $resObj->error->errors[0]->reason;
421421
}
422-
throw new \Exception($msg);
422+
throw new \Exception($msg,$resObj->error->code);
423423
} else {
424424
$this->page_info = array(
425425
'resultsPerPage' => $resObj->pageInfo->resultsPerPage,
@@ -472,7 +472,7 @@ public function api_get($url, $params)
472472
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
473473
$tuData = curl_exec($tuCurl);
474474
if (curl_errno($tuCurl)) {
475-
throw new \Exception('Curl Error : ' . curl_error($tuCurl));
475+
throw new \Exception('Curl Error : ' . curl_error($tuCurl),curl_error($tuCurl));
476476
}
477477
return $tuData;
478478
}

0 commit comments

Comments
 (0)