Refactor error handling and logging in DevChat dependency check
- Added a new optional parameter 'showError' in checkDevChatDependency function in commandsBase.ts. - Updated the conditions for logging error messages in checkDevChatDependency function. - Updated the call to checkDevChatDependency in dependencyCheck function in statusBarViewBase.ts to pass 'showError' parameter. - Updated the condition for logging stderr in CommandRun class in commonUtil.ts.
This commit is contained in:
parent
e1d939c7f7
commit
15141dd6ff
@ -23,7 +23,7 @@ function locateCommand(command): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkDevChatDependency(pythonCommand: string): boolean {
|
||||
export function checkDevChatDependency(pythonCommand: string, showError: boolean = true): boolean {
|
||||
let pipxBinPath: string | undefined = undefined;
|
||||
try {
|
||||
const binPath = getPipxEnvironmentPath(pythonCommand);
|
||||
@ -39,7 +39,7 @@ export function checkDevChatDependency(pythonCommand: string): boolean {
|
||||
}
|
||||
} else {
|
||||
const error_status = `Failed to obtain the pipx environment path.`;
|
||||
if (pipxPathStatus !== error_status) {
|
||||
if (pipxPathStatus !== error_status && showError) {
|
||||
logger.channel()?.warn(error_status);
|
||||
logger.channel()?.show();
|
||||
pipxPathStatus = error_status;
|
||||
@ -51,7 +51,7 @@ export function checkDevChatDependency(pythonCommand: string): boolean {
|
||||
// DevChat dependency check failed
|
||||
// log out detail error message
|
||||
const error_status = `Failed to check DevChat dependency due to error: ${error}`;
|
||||
if (pipxPathStatus !== error_status) {
|
||||
if (pipxPathStatus !== error_status && showError) {
|
||||
logger.channel()?.warn(error_status);
|
||||
logger.channel()?.show();
|
||||
pipxPathStatus = error_status;
|
||||
@ -75,7 +75,7 @@ export function checkDevChatDependency(pythonCommand: string): boolean {
|
||||
return true;
|
||||
} catch(error) {
|
||||
const error_status = `Failed to check DevChat dependency due to error: ${error}`;
|
||||
if (devchatStatus !== error_status) {
|
||||
if (devchatStatus !== error_status && showError) {
|
||||
logger.channel()?.warn(error_status);
|
||||
logger.channel()?.show();
|
||||
devchatStatus = error_status;
|
||||
|
@ -65,7 +65,8 @@ export async function dependencyCheck(): Promise<[string, string]> {
|
||||
}
|
||||
|
||||
if (!bOk) {
|
||||
bOk = checkDevChatDependency(pythonCommand!);
|
||||
const showError = devchatStatus == ''? false : true;
|
||||
bOk = checkDevChatDependency(pythonCommand!, showError);
|
||||
}
|
||||
if (bOk && versionChanged && !devChat) {
|
||||
bOk = false;
|
||||
|
@ -72,7 +72,7 @@ export class CommandRun {
|
||||
fs.writeFileSync(outputFile, outputData);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
if (stderr && !onError) {
|
||||
logger.channel()?.error(stderr);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user