- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathcore-error-handler.ts
32 lines (27 loc) · 908 Bytes
/
core-error-handler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import{Emitter,Event}from'@theia/core';
import{injectable}from'@theia/core/shared/inversify';
import{CoreError}from'../../common/protocol/core-service';
@injectable()
exportclassCoreErrorHandler{
privatereadonlyerrors: CoreError.ErrorLocation[]=[];
privatereadonlycompilerErrorsDidChangeEmitter=newEmitter<
CoreError.ErrorLocation[]
>();
tryHandle(error: unknown): void{
if(CoreError.is(error)){
this.errors.length=0;
this.errors.push(...error.data);
this.fireCompilerErrorsDidChange();
}
}
reset(): void{
this.errors.length=0;
this.fireCompilerErrorsDidChange();
}
getonCompilerErrorsDidChange(): Event<CoreError.ErrorLocation[]>{
returnthis.compilerErrorsDidChangeEmitter.event;
}
privatefireCompilerErrorsDidChange(): void{
this.compilerErrorsDidChangeEmitter.fire(this.errors.slice());
}
}