Better error handling

merge-requests/5/head
Terence Eden 2024-06-26 13:30:19 +01:00
rodzic dc533a57d0
commit f2a295e27e
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -1269,9 +1269,14 @@ HTML;
// Execute the cURL session
$urlJSON = curl_exec( $ch );
$status_code = curl_getinfo( $ch, CURLINFO_RESPONSE_CODE );
// Check for errors
if (curl_errno( $ch )) {
if ( curl_errno( $ch ) || $status_code == 404 ) {
// 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();
}