Skip to content

Commit f860cb5

Browse files
authored
Merge pull request #64 from ossinkine/upload-saver-error-explanation
2 parents f0519db + 268e75d commit f860cb5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Saver/UploadSaver.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,21 @@ private function submit($url, $payload)
6161
CURLOPT_TIMEOUT => $this->timeout,
6262
));
6363
if (!$res) {
64-
throw new ProfilerException('Failed to set cURL options');
64+
$error = curl_errno($ch) ? curl_error($ch) : '';
65+
throw new ProfilerException('Failed to set cURL options'.($error ? ': '.$error : ''));
6566
}
6667

6768
$result = curl_exec($ch);
6869
if ($result === false) {
69-
throw new ProfilerException('Failed to submit data');
70+
$error = curl_errno($ch) ? curl_error($ch) : '';
71+
throw new ProfilerException('Failed to submit data'.($error ? ': '.$error : ''));
7072
}
7173
curl_close($ch);
7274

7375
$response = json_decode($result, true);
7476
if (!$response) {
75-
throw new ProfilerException('Failed to decode response');
77+
$error = json_last_error() ? (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Error '.json_last_error()) : '';
78+
throw new ProfilerException('Failed to decode response'.($error ? ': '.$error : ''));
7679
}
7780

7881
if (isset($response['error']) && $response['error']) {

0 commit comments

Comments
 (0)