1
1
import { window , commands } from "vscode" ;
2
- import { ErrorHandler , Message , ErrorAction , CloseAction } from "vscode-languageclient" ;
2
+ import { ErrorHandler , Message , ErrorAction , CloseAction , ErrorHandlerResult , CloseHandlerResult } from "vscode-languageclient" ;
3
3
import { Commands } from "./commands" ;
4
4
import { logger } from "./log" ;
5
5
@@ -10,21 +10,27 @@ export class ClientErrorHandler implements ErrorHandler {
10
10
this . restarts = [ ] ;
11
11
}
12
12
13
- public error ( _error : Error , _message : Message , count : number ) : ErrorAction {
13
+ public error ( _error : Error , _message : Message , count : number ) : ErrorHandlerResult {
14
14
if ( count && count <= 3 ) {
15
15
logger . error ( `${ this . name } server encountered error: ${ _message } , ${ _error && _error . toString ( ) } ` ) ;
16
- return ErrorAction . Continue ;
16
+ return {
17
+ action : ErrorAction . Continue
18
+ } ;
17
19
}
18
20
19
21
logger . error ( `${ this . name } server encountered error and will shut down: ${ _message } , ${ _error && _error . toString ( ) } ` ) ;
20
- return ErrorAction . Shutdown ;
22
+ return {
23
+ action : ErrorAction . Shutdown
24
+ } ;
21
25
}
22
26
23
- public closed ( ) : CloseAction {
27
+ public closed ( ) : CloseHandlerResult {
24
28
this . restarts . push ( Date . now ( ) ) ;
25
29
if ( this . restarts . length < 5 ) {
26
30
logger . error ( `The ${ this . name } server crashed and will restart.` ) ;
27
- return CloseAction . Restart ;
31
+ return {
32
+ action : CloseAction . Restart
33
+ } ;
28
34
} else {
29
35
const diff = this . restarts [ this . restarts . length - 1 ] - this . restarts [ 0 ] ;
30
36
if ( diff <= 3 * 60 * 1000 ) {
@@ -36,12 +42,16 @@ export class ClientErrorHandler implements ErrorHandler {
36
42
commands . executeCommand ( Commands . OPEN_LOGS ) ;
37
43
}
38
44
} ) ;
39
- return CloseAction . DoNotRestart ;
45
+ return {
46
+ action : CloseAction . DoNotRestart
47
+ } ;
40
48
}
41
49
42
50
logger . error ( `The ${ this . name } server crashed and will restart.` ) ;
43
51
this . restarts . shift ( ) ;
44
- return CloseAction . Restart ;
52
+ return {
53
+ action : CloseAction . Restart
54
+ } ;
45
55
}
46
56
}
47
57
}
0 commit comments