@@ -7,12 +7,14 @@ import DeepCodeLib from "./lib/modules/DeepCodeLib";
77import {
88 DEEPCODE_START_COMMAND ,
99 DEEPCODE_SETTINGS_COMMAND ,
10+ DEEPCODE_DCIGNORE_COMMAND ,
1011 DEEPCODE_LOGIN ,
1112 DEEPCODE_APPROVE ,
1213 DEEPCODE_OPEN_BROWSER ,
1314 DEEPCODE_OPEN_LOCAL ,
1415} from "./constants/commands" ;
15- import { openDeepcodeSettingsCommand } from "./utils/vscodeCommandsUtils" ;
16+ import { openDeepcodeSettingsCommand , createDCIgnoreCommand } from "./utils/vscodeCommandsUtils" ;
17+ import { errorsLogs } from "./messages/errorsServerLogMessages" ;
1618
1719import {
1820 DEEPCODE_VIEW_SUPPORT ,
@@ -22,24 +24,42 @@ import { SupportProvider } from "./view/SupportProvider";
2224import { IssueProvider } from "./view/IssueProvider" ;
2325
2426class DeepCodeExtension extends DeepCodeLib implements DeepCode . ExtensionInterface {
27+ private async executeCommand (
28+ name : string ,
29+ fn : ( ...args : any [ ] ) => Promise < any > ,
30+ ...args : any [ ]
31+ ) : Promise < any > {
32+ try {
33+ await fn ( ...args ) ;
34+ } catch ( error ) {
35+ this . processError ( error , {
36+ message : errorsLogs . command ( name ) ,
37+ } ) ;
38+ }
39+ }
40+
2541 public activate ( context : vscode . ExtensionContext ) : void {
2642 this . statusBarItem . show ( ) ;
2743
2844 context . subscriptions . push (
2945 vscode . commands . registerCommand (
3046 DEEPCODE_OPEN_BROWSER ,
31- ( url : string ) => open ( url )
47+ this . executeCommand . bind (
48+ this ,
49+ DEEPCODE_OPEN_BROWSER ,
50+ ( url : string ) => open ( url )
51+ )
3252 )
3353 ) ;
3454
3555 context . subscriptions . push (
3656 vscode . commands . registerCommand (
3757 DEEPCODE_OPEN_LOCAL ,
3858 ( path : vscode . Uri , range ?: vscode . Range ) => {
39- console . log ( "DEEPCODE_OPEN_LOCAL" , path . toString ( ) ) ;
4059 vscode . window . showTextDocument ( path , { selection : range } ) . then (
41- ( f ) => console . log ( f ) ,
42- ( err ) => console . error ( err )
60+ ( ) => { } , ( err ) => this . processError ( err , {
61+ message : errorsLogs . command ( DEEPCODE_OPEN_LOCAL ) ,
62+ } )
4363 ) ;
4464 }
4565 )
@@ -48,28 +68,51 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4868 context . subscriptions . push (
4969 vscode . commands . registerCommand (
5070 DEEPCODE_LOGIN ,
51- this . initiateLogin . bind ( this )
71+ this . executeCommand . bind (
72+ this ,
73+ DEEPCODE_LOGIN ,
74+ this . initiateLogin . bind ( this )
75+ )
5276 )
5377 ) ;
5478
5579 context . subscriptions . push (
5680 vscode . commands . registerCommand (
5781 DEEPCODE_APPROVE ,
58- this . approveUpload . bind ( this )
82+ this . executeCommand . bind (
83+ this ,
84+ DEEPCODE_APPROVE ,
85+ this . approveUpload . bind ( this )
86+ )
5987 )
6088 ) ;
6189
6290 context . subscriptions . push (
6391 vscode . commands . registerCommand (
6492 DEEPCODE_START_COMMAND ,
65- this . startExtension . bind ( this )
93+ this . executeCommand . bind (
94+ this ,
95+ DEEPCODE_START_COMMAND ,
96+ this . startExtension . bind ( this )
97+ )
6698 )
6799 ) ;
68100
69101 context . subscriptions . push (
70102 vscode . commands . registerCommand (
71103 DEEPCODE_SETTINGS_COMMAND ,
72- openDeepcodeSettingsCommand
104+ this . executeCommand . bind (
105+ this ,
106+ DEEPCODE_SETTINGS_COMMAND ,
107+ openDeepcodeSettingsCommand
108+ )
109+ )
110+ ) ;
111+
112+ context . subscriptions . push (
113+ vscode . commands . registerCommand (
114+ DEEPCODE_DCIGNORE_COMMAND ,
115+ createDCIgnoreCommand
73116 )
74117 ) ;
75118
@@ -84,7 +127,9 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
84127 ) ;
85128
86129 this . activateAll ( ) ;
87- this . startExtension ( ) ;
130+ this . startExtension ( ) . catch ( ( err ) => this . processError ( err , {
131+ message : errorsLogs . failedExecution ,
132+ } ) ) ;
88133 }
89134
90135}
0 commit comments