feat: second error catch

This commit is contained in:
William Harrison authored and GitHub committed 2023-05-01 13:08:53 +08:00
1 parent a3725187cd
commit 65af93a166
1 file changed
+2
+2
View File
@@ -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 });
}