From 65af93a166dabb05ea9eee2157e5114c3fe7b3a0 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 1 May 2023 13:08:53 +0800 Subject: [PATCH] feat: second error catch --- scripts/ping.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ping.js b/scripts/ping.js index b9683c4..5ae5e79 100644 --- a/scripts/ping.js +++ b/scripts/ping.js @@ -6,6 +6,8 @@ const ping = (host) => { exec(`ping -c 1 ${host}`, (error, stdout, stderr) => { if (error) { reject(error); + } else if (stderr.match(/(unknown|unreachable|failure)/i)) { + reject(new Error(`Host unreachable: ${host}`)); } else { resolve({ stdout, stderr }); }