From 00e1db44b249d55049b25b1510ef938da68cd95c Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Mon, 1 Jul 2019 12:56:35 +0900 Subject: [PATCH] Fix unhandled exceptions in port-scanner. (eclipse#281) In case IPv6 was disabled, `/proc/net/tcp6` will not exist. (Probably IPv4 will be similar.) Signed-off-by: Masaki Muranaka --- plugins/ports-plugin/src/port-scanner.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/ports-plugin/src/port-scanner.ts b/plugins/ports-plugin/src/port-scanner.ts index 1382d507f6..59afe84258 100644 --- a/plugins/ports-plugin/src/port-scanner.ts +++ b/plugins/ports-plugin/src/port-scanner.ts @@ -29,8 +29,12 @@ export class PortScanner { const ipConverter = new IpConverter(); // connect to /proc/net/tcp and /proc/net/tcp6 const command = new Command(__dirname); - const outputv4 = await command.exec(PortScanner.GRAB_PORTS_IPV4); - const outputv6 = await command.exec(PortScanner.GRAB_PORTS_IPV6); + const outputv4 = await command + .exec(PortScanner.GRAB_PORTS_IPV4) + .catch(e => { console.error(e); return ''; }); + const outputv6 = await command + .exec(PortScanner.GRAB_PORTS_IPV6) + .catch(e => { console.error(e); return ''; }); // assembe ipv4 and ipv6 output const output = `