Handle .NET Failed: Undefined (#1930)
Rejecting a promise with a rejected promise as a return value from a function does not reject with the object the inner promise rejected with. Instead it rejects with an undefined value. This means if the SDK installer fails or we fail to elevate, that counts as .NET Install failed: undefined. This fixes this. It also adds a check for the string error as this seems to happen sometimes if the password prompt is rejected. How to test this? Set a break point in win mac global installer on the execute install and edit the command to point to a non existent file. It will then fail and you can see it works now.
This commit is contained in:
Родитель
ffc2590f5e
Коммит
d57a31f3c8
|
@ -421,7 +421,7 @@ with options ${JSON.stringify(options)}.`));
|
|||
this.context?.eventStream.post(new CommandExecutionStdError(`The command ${fullCommandString} encountered ERROR: ${JSON.stringify(error)}`));
|
||||
}
|
||||
|
||||
return resolve({ status: error ? error.code : '0', stderr: execStderr, stdout: execStdout} as CommandExecutorResult);
|
||||
return resolve({ status: error?.code ? error.code : '0', stderr: execStderr, stdout: execStdout} as CommandExecutorResult);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -477,25 +477,31 @@ ${commandResult.stdout}`));
|
|||
${commandResult.stderr}`));
|
||||
}
|
||||
|
||||
private parseVSCodeSudoExecError(error : any, fullCommandString : string)
|
||||
private parseVSCodeSudoExecError(error : any, fullCommandString : string) : Error
|
||||
{
|
||||
if(error.code === 126)
|
||||
// 'permission' comes from an unlocalized string: https://github.com/bpasero/sudo-prompt/blob/21d9308edcf970f0a9ee0580c539b1457b3dc45b/index.js#L678
|
||||
// if you reject on the password prompt on windows before SDK window pops up, no code will be set, so we need to check for this string.
|
||||
if(error?.code === 126 || (error?.message as string)?.includes('permission'))
|
||||
{
|
||||
const cancelledErr = new CommandExecutionUserRejectedPasswordRequest(new EventCancellationError('CommandExecutionUserRejectedPasswordRequest',
|
||||
`Cancelling .NET Install, as command ${fullCommandString} failed.
|
||||
The user refused the password prompt.`),
|
||||
getInstallFromContext(this.context));
|
||||
this.context?.eventStream.post(cancelledErr);
|
||||
return Promise.reject(cancelledErr.error);
|
||||
return cancelledErr.error;
|
||||
}
|
||||
else if(error.code === 111777)
|
||||
else if(error?.code === 111777)
|
||||
{
|
||||
const securityErr = new CommandExecutionUnknownCommandExecutionAttempt(new EventCancellationError('CommandExecutionUnknownCommandExecutionAttempt',
|
||||
`Cancelling .NET Install, as command ${fullCommandString} is UNKNOWN.
|
||||
Please report this at https://github.com/dotnet/vscode-dotnet-runtime/issues.`),
|
||||
getInstallFromContext(this.context));
|
||||
this.context?.eventStream.post(securityErr);
|
||||
return Promise.reject(securityErr.error);
|
||||
return securityErr.error;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ export class WebRequestWorker
|
|||
}
|
||||
catch(error : any)
|
||||
{
|
||||
if(error && error?.message && (error?.message as string)?.includes('ENOSPC'))
|
||||
if(error?.message && (error?.message as string)?.includes('ENOSPC'))
|
||||
{
|
||||
const err = new DiskIsFullError(new EventBasedError('DiskIsFullError',
|
||||
`You don't have enough space left on your disk to install the .NET SDK. Please clean up some space.`), getInstallFromContext(this.context));
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
"settings": {
|
||||
"cSpell.words": [
|
||||
"DOTNETINSTALLMODELIST",
|
||||
"Republisher"
|
||||
"Republisher",
|
||||
"unlocalized"
|
||||
]
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче