@@ -8,12 +8,14 @@ import {
88 DEEPCODE_START_COMMAND ,
99 DEEPCODE_SETMODE_COMMAND ,
1010 DEEPCODE_SETTINGS_COMMAND ,
11+ DEEPCODE_DCIGNORE_COMMAND ,
1112 DEEPCODE_LOGIN ,
1213 DEEPCODE_APPROVE ,
1314 DEEPCODE_OPEN_BROWSER ,
1415 DEEPCODE_OPEN_LOCAL ,
1516} from "./constants/commands" ;
16- import { openDeepcodeSettingsCommand } from "./utils/vscodeCommandsUtils" ;
17+ import { openDeepcodeSettingsCommand , createDCIgnoreCommand } from "./utils/vscodeCommandsUtils" ;
18+ import { errorsLogs } from "./messages/errorsServerLogMessages" ;
1719
1820import {
1921 DEEPCODE_VIEW_SUPPORT ,
@@ -23,24 +25,42 @@ import { SupportProvider } from "./view/SupportProvider";
2325import { IssueProvider } from "./view/IssueProvider" ;
2426
2527class DeepCodeExtension extends DeepCodeLib implements DeepCode . ExtensionInterface {
28+ private async executeCommand (
29+ name : string ,
30+ fn : ( ...args : any [ ] ) => Promise < any > ,
31+ ...args : any [ ]
32+ ) : Promise < any > {
33+ try {
34+ await fn ( ...args ) ;
35+ } catch ( error ) {
36+ this . processError ( error , {
37+ message : errorsLogs . command ( name ) ,
38+ } ) ;
39+ }
40+ }
41+
2642 public activate ( context : vscode . ExtensionContext ) : void {
2743 this . statusBarItem . show ( ) ;
2844
2945 context . subscriptions . push (
3046 vscode . commands . registerCommand (
3147 DEEPCODE_OPEN_BROWSER ,
32- ( url : string ) => open ( url )
48+ this . executeCommand . bind (
49+ this ,
50+ DEEPCODE_OPEN_BROWSER ,
51+ ( url : string ) => open ( url )
52+ )
3353 )
3454 ) ;
3555
3656 context . subscriptions . push (
3757 vscode . commands . registerCommand (
3858 DEEPCODE_OPEN_LOCAL ,
3959 ( path : vscode . Uri , range ?: vscode . Range ) => {
40- console . log ( "DEEPCODE_OPEN_LOCAL" , path . toString ( ) ) ;
4160 vscode . window . showTextDocument ( path , { selection : range } ) . then (
42- ( f ) => console . log ( f ) ,
43- ( err ) => console . error ( err )
61+ ( ) => { } , ( err ) => this . processError ( err , {
62+ message : errorsLogs . command ( DEEPCODE_OPEN_LOCAL ) ,
63+ } )
4464 ) ;
4565 }
4666 )
@@ -49,21 +69,33 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4969 context . subscriptions . push (
5070 vscode . commands . registerCommand (
5171 DEEPCODE_LOGIN ,
52- this . initiateLogin . bind ( this )
72+ this . executeCommand . bind (
73+ this ,
74+ DEEPCODE_LOGIN ,
75+ this . initiateLogin . bind ( this )
76+ )
5377 )
5478 ) ;
5579
5680 context . subscriptions . push (
5781 vscode . commands . registerCommand (
5882 DEEPCODE_APPROVE ,
59- this . approveUpload . bind ( this )
83+ this . executeCommand . bind (
84+ this ,
85+ DEEPCODE_APPROVE ,
86+ this . approveUpload . bind ( this )
87+ )
6088 )
6189 ) ;
6290
6391 context . subscriptions . push (
6492 vscode . commands . registerCommand (
6593 DEEPCODE_START_COMMAND ,
66- this . startExtension . bind ( this , true )
94+ this . executeCommand . bind (
95+ this ,
96+ DEEPCODE_START_COMMAND ,
97+ this . startExtension . bind ( this )
98+ )
6799 )
68100 ) ;
69101
@@ -77,7 +109,18 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
77109 context . subscriptions . push (
78110 vscode . commands . registerCommand (
79111 DEEPCODE_SETTINGS_COMMAND ,
80- openDeepcodeSettingsCommand
112+ this . executeCommand . bind (
113+ this ,
114+ DEEPCODE_SETTINGS_COMMAND ,
115+ openDeepcodeSettingsCommand
116+ )
117+ )
118+ ) ;
119+
120+ context . subscriptions . push (
121+ vscode . commands . registerCommand (
122+ DEEPCODE_DCIGNORE_COMMAND ,
123+ createDCIgnoreCommand
81124 )
82125 ) ;
83126
@@ -92,7 +135,9 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
92135 ) ;
93136
94137 this . activateAll ( ) ;
95- this . startExtension ( ) ;
138+ this . startExtension ( ) . catch ( ( err ) => this . processError ( err , {
139+ message : errorsLogs . failedExecution ,
140+ } ) ) ;
96141 }
97142
98143}
0 commit comments