transload error log-ish

This commit is contained in:
Shish 2020-01-26 23:23:01 +00:00
parent b98dd3dd76
commit 50f3d04f0c
2 changed files with 7 additions and 1 deletions

View file

@ -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;
}

View file

@ -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)))));