Better error handling
rodzic
dc533a57d0
commit
f2a295e27e
|
@ -1269,9 +1269,14 @@ HTML;
|
||||||
// Execute the cURL session
|
// Execute the cURL session
|
||||||
$urlJSON = curl_exec( $ch );
|
$urlJSON = curl_exec( $ch );
|
||||||
|
|
||||||
|
$status_code = curl_getinfo( $ch, CURLINFO_RESPONSE_CODE );
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if (curl_errno( $ch )) {
|
if ( curl_errno( $ch ) || $status_code == 404 ) {
|
||||||
// Handle cURL error
|
// Handle cURL error
|
||||||
|
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
||||||
|
$error_message = curl_error( $ch ) . "\nURl: {$url}\nHeaders: " . json_encode( $headers );
|
||||||
|
file_put_contents( $directories["logs"] . "/{$timestamp}.Error.txt", $error_message );
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue