Skip to content

Commit a5f92a2

Browse files
committed
Refactored code to use await and try catch pattern
1 parent 651e67d commit a5f92a2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

vscode/src/extension.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,17 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
520520
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace and reload the window ?',
521521
'Yes', 'Cancel');
522522
if (confirmation === 'Yes') {
523-
stopClient(client).then(() => { deactivated=true;
524-
return killNbProcess(false, log);})
525-
.then(() => fs.promises.rmdir(userDir, {recursive : true}))
526-
.then(()=>vscode.window.showInformationMessage("Cache deleted successfully",'Reload window'),
527-
(err)=> vscode.window.showErrorMessage('Error deleting the cache','Reload window'))
528-
.then(()=> {vscode.commands.executeCommand("workbench.action.reloadWindow")});
523+
try{
524+
await stopClient(client);
525+
deactivated=true;
526+
await killNbProcess(false,log);
527+
await fs.promises.rmdir(userDir, {recursive : true});
528+
await vscode.window.showInformationMessage("Cache deleted successfully",'Reload window');
529+
}catch(err){
530+
await vscode.window.showErrorMessage('Error deleting the cache','Reload window');
531+
}finally{
532+
vscode.commands.executeCommand("workbench.action.reloadWindow");
533+
}
529534
}
530535
} else {
531536
vscode.window.showErrorMessage('Cannot find userdir path');

0 commit comments

Comments
 (0)