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.
This commit is contained in:
Asher 2020-10-27 17:41:11 -05:00
parent dc177ab505
commit 504d89638b
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 5 additions and 3 deletions

View File

@ -162,10 +162,12 @@ const main = async (args: DefaultedArgs): Promise<void> => {
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}`)
}
}
}