Expose sanitized Portainer connection errors
This commit is contained in:
@@ -195,7 +195,9 @@ function pnpaas_portainer_request(string $path, string $method = 'GET', ?array $
|
||||
curl_close($handle);
|
||||
|
||||
if ($body === false || $error !== '') {
|
||||
throw new RuntimeException('Portainer ist nicht erreichbar.');
|
||||
$detail = trim($error);
|
||||
$detail = preg_replace('/(?:X-API-Key|Authorization|Bearer)\s*:\s*[^\s,;]+/i', '[credential redacted]', $detail) ?? $detail;
|
||||
throw new RuntimeException('Portainer ist nicht erreichbar' . ($detail !== '' ? ': ' . substr($detail, 0, 400) : '.'));
|
||||
}
|
||||
if ($status < 200 || ($status >= 300 && $status !== 304)) {
|
||||
$detail = trim(preg_replace('/\s+/', ' ', (string)$body) ?? '');
|
||||
|
||||
Reference in New Issue
Block a user