mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-09 03:18:33 +00:00

* Notify the LS about the new `build_path` after verify. Closes #714 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
33 lines
908 B
TypeScript
33 lines
908 B
TypeScript
import { Emitter, Event } from '@theia/core';
|
|
import { injectable } from '@theia/core/shared/inversify';
|
|
import { CoreError } from '../../common/protocol/core-service';
|
|
|
|
@injectable()
|
|
export class CoreErrorHandler {
|
|
private readonly errors: CoreError.ErrorLocation[] = [];
|
|
private readonly compilerErrorsDidChangeEmitter = new Emitter<
|
|
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();
|
|
}
|
|
|
|
get onCompilerErrorsDidChange(): Event<CoreError.ErrorLocation[]> {
|
|
return this.compilerErrorsDidChangeEmitter.event;
|
|
}
|
|
|
|
private fireCompilerErrorsDidChange(): void {
|
|
this.compilerErrorsDidChangeEmitter.fire(this.errors.slice());
|
|
}
|
|
}
|