From 50f3d04f0c425022657a5f358d63995d97e88bd7 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 26 Jan 2020 23:23:01 +0000 Subject: [PATCH] transload error log-ish --- core/config.php | 4 +++- core/util.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/config.php b/core/config.php index ca667924..1b030d6f 100644 --- a/core/config.php +++ b/core/config.php @@ -214,7 +214,9 @@ abstract class BaseConfig implements Config public function get_string(string $name, ?string $default=null): ?string { $val = $this->get($name, $default); - if(!is_string($val) && !is_null($val)) throw new SCoreException("$name is not a string: $val"); + if (!is_string($val) && !is_null($val)) { + throw new SCoreException("$name is not a string: $val"); + } return $val; } diff --git a/core/util.php b/core/util.php index cf30650b..4e3c333b 100644 --- a/core/util.php +++ b/core/util.php @@ -208,6 +208,10 @@ function transload(string $url, string $mfile): ?array curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $response = curl_exec($ch); + if ($response === false) { + log_warning("core-util", "Failed to transload $url"); + throw new SCoreException("Failed to fetch $url"); + } $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headers = http_parse_headers(implode("\n", preg_split('/\R/', rtrim(substr($response, 0, $header_size)))));