crc-org / tray-electron

Archive of the Desktop/tray application of CRC Runs Containers
https://crc.dev
Apache License 2.0
4 stars 5 forks source link

Wrap the API call in a try-catch for `get-about` event #183

Closed gbraad closed 2 years ago

gbraad commented 2 years ago

For the code: https://github.com/code-ready/tray-electron/blob/d8d46a3f191a67fb5592500311dac523c55dd9e7/src/main.ts#L1023-L1032

It is suggested to do something like:

ipcMain.handle('get-about', async () => {
  try {
    const version = await commander.version();
    return {
      appVersion: app.getVersion(),
      crcVersion: version.CrcVersion,
      crcCommit: version.CommitSha,
      ocpBundleVersion: version.OpenshiftVersion,
      podmanVersion: version.PodmanVersion
    };
  } catch(e) {
    console.log(e)
  }
});

else the exception will be uncaught and cause issues with the main process.