From f2a295e27e5b2efecc398e54622241531554bd71 Mon Sep 17 00:00:00 2001 From: Terence Eden Date: Wed, 26 Jun 2024 13:30:19 +0100 Subject: [PATCH] Better error handling --- index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index b51adab..4af3ed3 100644 --- a/index.php +++ b/index.php @@ -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(); }