const singleErrorHandlers:()

in server/src/eslintServer.ts [1532:1572]


const singleErrorHandlers: ((error: any, document: TextDocument, library: ESLintModule) => Status | undefined)[] = [
	tryHandleNoConfig,
	tryHandleConfigError,
	tryHandleMissingModule,
	showErrorMessage
];

function validateSingle(document: TextDocument, publishDiagnostics: boolean = true): Promise<void> {
	// We validate document in a queue but open / close documents directly. So we need to deal with the
	// fact that a document might be gone from the server.
	if (!documents.get(document.uri)) {
		return Promise.resolve(undefined);
	}
	return resolveSettings(document).then(async (settings) => {
		if (settings.validate !== Validate.on || !TextDocumentSettings.hasLibrary(settings)) {
			return;
		}
		try {
			await validate(document, settings, publishDiagnostics);
			connection.sendNotification(StatusNotification.type, { uri: document.uri, state: Status.ok });
		} catch (err) {
			// if an exception has occurred while validating clear all errors to ensure
			// we are not showing any stale once
			connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
			if (!settings.silent) {
				let status: Status | undefined = undefined;
				for (const handler of singleErrorHandlers) {
					status = handler(err, document, settings.library);
					if (status) {
						break;
					}
				}
				status = status || Status.error;
				connection.sendNotification(StatusNotification.type, { uri: document.uri, state: status });
			} else {
				connection.console.info(getMessage(err, document));
				connection.sendNotification(StatusNotification.type, { uri: document.uri, state: Status.ok });
			}
		}
	});
}