Improve error messages in FileSystem::fetch()

This commit is contained in:
Giuseppe Criscione 2020-02-15 12:46:42 +01:00
parent de0d635917
commit 45e9a33f59

View File

@ -374,7 +374,12 @@ class FileSystem
}
$data = @file_get_contents($source, false, $context);
if ($data === false) {
throw new RuntimeException('Cannot fetch ' . $source);
$message = error_get_last()['message'] ?? '';
// Stream errors are in the form %s(%s):%s, we only need the trailing part
if (preg_match('/^.*\(.*\)(:.*)/', $message, $matches)) {
$message = $matches[1];
}
throw new RuntimeException('Cannot fetch ' . $source . $message);
}
return $data;
}