@@ -14,6 +14,7 @@ import {
1414 DEEPCODE_OPEN_LOCAL ,
1515} from "./constants/commands" ;
1616import { openDeepcodeSettingsCommand , createDCIgnoreCommand } from "./utils/vscodeCommandsUtils" ;
17+ import { errorsLogs } from "./messages/errorsServerLogMessages" ;
1718
1819import {
1920 DEEPCODE_VIEW_SUPPORT ,
@@ -23,24 +24,42 @@ import { SupportProvider } from "./view/SupportProvider";
2324import { IssueProvider } from "./view/IssueProvider" ;
2425
2526class 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+
2641 public activate ( context : vscode . ExtensionContext ) : void {
2742 this . statusBarItem . show ( ) ;
2843
2944 context . subscriptions . push (
3045 vscode . commands . registerCommand (
3146 DEEPCODE_OPEN_BROWSER ,
32- ( url : string ) => open ( url )
47+ this . executeCommand . bind (
48+ this ,
49+ DEEPCODE_OPEN_BROWSER ,
50+ ( url : string ) => open ( url )
51+ )
3352 )
3453 ) ;
3554
3655 context . subscriptions . push (
3756 vscode . commands . registerCommand (
3857 DEEPCODE_OPEN_LOCAL ,
3958 ( path : vscode . Uri , range ?: vscode . Range ) => {
40- console . log ( "DEEPCODE_OPEN_LOCAL" , path . toString ( ) ) ;
4159 vscode . window . showTextDocument ( path , { selection : range } ) . then (
42- ( f ) => console . log ( f ) ,
43- ( err ) => console . error ( err )
60+ ( ) => { } , ( err ) => this . processError ( err , {
61+ message : errorsLogs . command ( DEEPCODE_OPEN_LOCAL ) ,
62+ } )
4463 ) ;
4564 }
4665 )
@@ -49,28 +68,44 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4968 context . subscriptions . push (
5069 vscode . commands . registerCommand (
5170 DEEPCODE_LOGIN ,
52- this . initiateLogin . bind ( this )
71+ this . executeCommand . bind (
72+ this ,
73+ DEEPCODE_LOGIN ,
74+ this . initiateLogin . bind ( this )
75+ )
5376 )
5477 ) ;
5578
5679 context . subscriptions . push (
5780 vscode . commands . registerCommand (
5881 DEEPCODE_APPROVE ,
59- this . approveUpload . bind ( this )
82+ this . executeCommand . bind (
83+ this ,
84+ DEEPCODE_APPROVE ,
85+ this . approveUpload . bind ( this )
86+ )
6087 )
6188 ) ;
6289
6390 context . subscriptions . push (
6491 vscode . commands . registerCommand (
6592 DEEPCODE_START_COMMAND ,
66- this . startExtension . bind ( this )
93+ this . executeCommand . bind (
94+ this ,
95+ DEEPCODE_START_COMMAND ,
96+ this . startExtension . bind ( this )
97+ )
6798 )
6899 ) ;
69100
70101 context . subscriptions . push (
71102 vscode . commands . registerCommand (
72103 DEEPCODE_SETTINGS_COMMAND ,
73- openDeepcodeSettingsCommand
104+ this . executeCommand . bind (
105+ this ,
106+ DEEPCODE_SETTINGS_COMMAND ,
107+ openDeepcodeSettingsCommand
108+ )
74109 )
75110 ) ;
76111
@@ -92,7 +127,9 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
92127 ) ;
93128
94129 this . activateAll ( ) ;
95- this . startExtension ( ) ;
130+ this . startExtension ( ) . catch ( ( err ) => this . processError ( err , {
131+ message : errorsLogs . failedExecution ,
132+ } ) ) ;
96133 }
97134
98135}
0 commit comments