From 504d89638b4b55a62ffc65144cce6a140aedcde5 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 27 Oct 2020 17:41:11 -0500 Subject: [PATCH] Fix open line being printed when open fails Opening the URL can fail if the user doesn't have something appropriate installed to handle it. --- src/node/entry.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/node/entry.ts b/src/node/entry.ts index 890ad6ae..df218a52 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -162,10 +162,12 @@ const main = async (args: DefaultedArgs): Promise => { if (!args.socket && args.open) { // The web socket doesn't seem to work if browsing with 0.0.0.0. const openAddress = serverAddress.replace("://0.0.0.0", "://localhost") - await open(openAddress).catch((error: Error) => { + try { + await open(openAddress) + logger.info(`Opened ${openAddress}`) + } catch (error) { logger.error("Failed to open", field("address", openAddress), field("error", error)) - }) - logger.info(`Opened ${openAddress}`) + } } }