@@ -13,6 +13,7 @@ import {
1313 DEEPCODE_OPEN_LOCAL ,
1414} from "./constants/commands" ;
1515import { openDeepcodeSettingsCommand } from "./utils/vscodeCommandsUtils" ;
16+ import { errorsLogs } from "./messages/errorsServerLogMessages" ;
1617
1718import {
1819 DEEPCODE_VIEW_SUPPORT ,
@@ -22,24 +23,42 @@ import { SupportProvider } from "./view/SupportProvider";
2223import { IssueProvider } from "./view/IssueProvider" ;
2324
2425class DeepCodeExtension extends DeepCodeLib implements DeepCode . ExtensionInterface {
26+ private async executeCommand (
27+ name : string ,
28+ fn : ( ...args : any [ ] ) => Promise < any > ,
29+ ...args : any [ ]
30+ ) : Promise < any > {
31+ try {
32+ await fn ( ...args ) ;
33+ } catch ( error ) {
34+ this . processError ( error , {
35+ message : errorsLogs . command ( name ) ,
36+ } ) ;
37+ }
38+ }
39+
2540 public activate ( context : vscode . ExtensionContext ) : void {
2641 this . statusBarItem . show ( ) ;
2742
2843 context . subscriptions . push (
2944 vscode . commands . registerCommand (
3045 DEEPCODE_OPEN_BROWSER ,
31- ( url : string ) => open ( url )
46+ this . executeCommand . bind (
47+ this ,
48+ DEEPCODE_OPEN_BROWSER ,
49+ ( url : string ) => open ( url )
50+ )
3251 )
3352 ) ;
3453
3554 context . subscriptions . push (
3655 vscode . commands . registerCommand (
3756 DEEPCODE_OPEN_LOCAL ,
3857 ( path : vscode . Uri , range ?: vscode . Range ) => {
39- console . log ( "DEEPCODE_OPEN_LOCAL" , path . toString ( ) ) ;
4058 vscode . window . showTextDocument ( path , { selection : range } ) . then (
41- ( f ) => console . log ( f ) ,
42- ( err ) => console . error ( err )
59+ ( ) => { } , ( err ) => this . processError ( err , {
60+ message : errorsLogs . command ( DEEPCODE_OPEN_LOCAL ) ,
61+ } )
4362 ) ;
4463 }
4564 )
@@ -48,28 +67,44 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4867 context . subscriptions . push (
4968 vscode . commands . registerCommand (
5069 DEEPCODE_LOGIN ,
51- this . initiateLogin . bind ( this )
70+ this . executeCommand . bind (
71+ this ,
72+ DEEPCODE_LOGIN ,
73+ this . initiateLogin . bind ( this )
74+ )
5275 )
5376 ) ;
5477
5578 context . subscriptions . push (
5679 vscode . commands . registerCommand (
5780 DEEPCODE_APPROVE ,
58- this . approveUpload . bind ( this )
81+ this . executeCommand . bind (
82+ this ,
83+ DEEPCODE_APPROVE ,
84+ this . approveUpload . bind ( this )
85+ )
5986 )
6087 ) ;
6188
6289 context . subscriptions . push (
6390 vscode . commands . registerCommand (
6491 DEEPCODE_START_COMMAND ,
65- this . startExtension . bind ( this )
92+ this . executeCommand . bind (
93+ this ,
94+ DEEPCODE_START_COMMAND ,
95+ this . startExtension . bind ( this )
96+ )
6697 )
6798 ) ;
6899
69100 context . subscriptions . push (
70101 vscode . commands . registerCommand (
71102 DEEPCODE_SETTINGS_COMMAND ,
72- openDeepcodeSettingsCommand
103+ this . executeCommand . bind (
104+ this ,
105+ DEEPCODE_SETTINGS_COMMAND ,
106+ openDeepcodeSettingsCommand
107+ )
73108 )
74109 ) ;
75110
@@ -84,7 +119,9 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
84119 ) ;
85120
86121 this . activateAll ( ) ;
87- this . startExtension ( ) ;
122+ this . startExtension ( ) . catch ( ( err ) => this . processError ( err , {
123+ message : errorsLogs . failedExecution ,
124+ } ) ) ;
88125 }
89126
90127}
0 commit comments