Fix incorrect .NET error (#16694)

* Fix .NET Install state for error conditions

* Address comment- remove redundant constructor
This commit is contained in:
Sakshi Sharma
2021-08-11 11:29:48 -07:00
committed by GitHub
parent a4b1e8af96
commit 4250556023
2 changed files with 24 additions and 12 deletions

View File

@@ -148,15 +148,21 @@ export class NetCoreTool {
child.on('exit', () => {
this.netCoreSdkInstalledVersion = Buffer.concat(stdoutBuffers).toString('utf8').trim();
if (semver.gte(this.netCoreSdkInstalledVersion, minSupportedNetCoreVersion)) { // Net core version greater than or equal to minSupportedNetCoreVersion are supported for Build
isSupported = true;
} else {
isSupported = false;
try {
if (semver.gte(this.netCoreSdkInstalledVersion, minSupportedNetCoreVersion)) { // Net core version greater than or equal to minSupportedNetCoreVersion are supported for Build
isSupported = true;
} else {
isSupported = false;
}
resolve({ stdout: this.netCoreSdkInstalledVersion });
} catch (err) {
console.log(err);
reject(err);
}
resolve({ stdout: this.netCoreSdkInstalledVersion });
});
child.on('error', (err) => {
console.log(err);
this.netCoreInstallState = netCoreInstallState.netCoreNotPresent;
reject(err);
});
});
@@ -170,7 +176,7 @@ export class NetCoreTool {
return isSupported;
} catch (err) {
console.log(err);
this.netCoreInstallState = netCoreInstallState.netCoreVersionNotSupported;
this.netCoreInstallState = netCoreInstallState.netCoreNotPresent;
return undefined;
}
}
@@ -182,9 +188,9 @@ export class NetCoreTool {
if (!(await this.findOrInstallNetCore())) {
if (this.netCoreInstallState === netCoreInstallState.netCoreNotPresent) {
throw new Error(NetCoreInstallationConfirmation);
throw new DotNetError(NetCoreInstallationConfirmation);
} else {
throw new Error(NetCoreSupportedVersionInstallationConfirmation(this.netCoreSdkInstalledVersion!));
throw new DotNetError(NetCoreSupportedVersionInstallationConfirmation(this.netCoreSdkInstalledVersion!));
}
}
@@ -246,3 +252,7 @@ export class NetCoreTool {
});
}
}
export class DotNetError extends Error {
}