Skip to content

Commit

Permalink
Merge pull request #340 from microsoft/rethrow
Browse files Browse the repository at this point in the history
Rethrow Release require exception if Debug require fails
  • Loading branch information
Tyriar authored Aug 6, 2019
2 parents 8c89c19 + da04f39 commit 7bd4c73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
20 changes: 16 additions & 4 deletions src/windowsPtyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 7bd4c73

Please sign in to comment.