@@ -108,6 +108,12 @@ function benten_ls_exists(executable) {
108
108
}
109
109
110
110
111
+ function show_err_msg ( msg ) {
112
+ console . error ( msg )
113
+ window . showErrorMessage ( msg ) ;
114
+ }
115
+
116
+
111
117
function get_redirect ( url , callback ) {
112
118
http . get ( url , ( response ) => {
113
119
if ( response . headers . location ) {
@@ -118,7 +124,8 @@ function get_redirect(url, callback) {
118
124
callback ( response ) ;
119
125
}
120
126
} ) . on ( 'error' , ( e ) => {
121
- console . log ( `Connection error: ${ e } ` ) ;
127
+ const msg = `Failed trying to download Benten server binaries from ${ url } . Site responded with ${ e } ` ;
128
+ show_err_msg ( msg ) ;
122
129
} ) ;
123
130
}
124
131
@@ -154,27 +161,36 @@ function get_language_server(callback) {
154
161
fs . mkdir ( sbgdir , { recursive : true } , ( err ) => {
155
162
if ( err ) {
156
163
// Couldn't make the directory
157
- console . error ( `Could not create directory for downloaded package!` )
164
+ const msg = `Failed to create directory: ${ sbgdir } . This is where the downloaded Benten server binaries would have been stored.` ;
165
+ show_err_msg ( msg ) ;
158
166
callback ( null ) ;
159
167
}
160
168
161
169
// Download from github releases page
162
170
const package_url = `${ github_release_url } /${ pkgname } ` ;
163
171
console . log ( `Downloading server code from ${ package_url } ` ) ;
164
172
get_redirect ( package_url , ( response ) => {
165
- const { statusCode } = response ;
166
- console . log ( `Server response: ${ response . statusCode } ${ response . statusMessage } ` ) ;
173
+ const server_response = `Server response: ${ response . statusCode } ${ response . statusMessage } ` ;
174
+ if ( response . statusCode != 200 ) {
175
+ const msg = `Failed to download Benten server binary from ${ package_url } . ${ server_response } ` ;
176
+ show_err_msg ( msg ) ;
177
+ callback ( null ) ;
178
+ } else {
179
+ console . log ( server_response ) ;
180
+ }
167
181
168
182
// The github zip contains only one file: benten-ls.tar.gz
169
183
response . pipe ( unzip . Parse ( ) )
170
184
. on ( 'entry' , ( entry ) => {
171
185
entry . pipe ( gunzip ( ) ) . pipe ( tar . extract ( sbgdir ) )
172
186
. on ( 'finish' , ( ) => {
173
- console . log ( "Extracted!" ) ;
187
+ console . log ( "Extracted server binary !" ) ;
174
188
callback ( executable ) ;
175
189
} )
176
190
. on ( 'error' , ( e ) => {
177
- console . log ( `Error extracting: ${ e } ` ) ;
191
+ const msg = `Error extracting Benten server binary: ${ e } ` ;
192
+ show_err_msg ( msg ) ;
193
+ callback ( null ) ;
178
194
} ) ;
179
195
} ) ;
180
196
} ) ;
@@ -187,7 +203,7 @@ export function activate(context: ExtensionContext) {
187
203
// For the language server
188
204
get_language_server ( ( executable ) => {
189
205
if ( executable === null ) {
190
- console . error ( "Could not find or download language server.") ;
206
+ show_err_msg ( "Did not find installed Benten server and could not download Benten server binary .") ;
191
207
return ;
192
208
}
193
209
const args = [ "--debug" ]
0 commit comments