diff --git a/src/unixTerminal.ts b/src/unixTerminal.ts index 526adcd5e..44a3383dc 100644 --- a/src/unixTerminal.ts +++ b/src/unixTerminal.ts @@ -12,8 +12,14 @@ import { assign } from './utils'; let pty: IUnixNative; try { pty = require('../build/Release/pty.node'); -} catch { - pty = require('../build/Debug/pty.node'); +} catch (outerError) { + try { + pty = require('../build/Debug/pty.node'); + } catch (innerError) { + console.error('innerError', innerError); + // Re-throw the exception from the Release require if the Debug require fails as well + throw outerError; + } } const DEFAULT_FILE = 'sh'; diff --git a/src/windowsPtyAgent.ts b/src/windowsPtyAgent.ts index 141218062..cf8b65db6 100644 --- a/src/windowsPtyAgent.ts +++ b/src/windowsPtyAgent.ts @@ -61,16 +61,28 @@ export class WindowsPtyAgent { if (!conptyNative) { try { conptyNative = require('../build/Release/conpty.node'); - } catch (err) { - conptyNative = require('../build/Debug/conpty.node'); + } catch (outerError) { + try { + conptyNative = require('../build/Debug/conpty.node'); + } catch (innerError) { + console.error('innerError', innerError); + // Re-throw the exception from the Release require if the Debug require fails as well + throw outerError; + } } } } else { if (!winptyNative) { try { winptyNative = require('../build/Release/pty.node'); - } catch (err) { - winptyNative = require('../build/Debug/pty.node'); + } catch (outerError) { + try { + winptyNative = require('../build/Debug/pty.node'); + } catch (innerError) { + console.error('innerError', innerError); + // Re-throw the exception from the Release require if the Debug require fails as well + throw outerError; + } } } }