<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

export const IRemoteAuthorityResolverService = createDecorator<IRemoteAuthorityResolverService>('remoteAuthorityResolverService');

export interface ResolvedAuthority {
	readonly authority: string;
	readonly host: string;
	readonly port: number;
}

export enum RemoteAuthorityResolverErrorCode {
	Unknown = 'Unknown',
	NotAvailable = 'NotAvailable',
	TemporarilyNotAvailable = 'TemporarilyNotAvailable',
}

export class RemoteAuthorityResolverError extends Error {

	public static isHandledNotAvailable(err: any): boolean {
		if (err instanceof RemoteAuthorityResolverError) {
			if (err._code === RemoteAuthorityResolverErrorCode.NotAvailable && err._detail === true) {
				return true;
			}
		}
		return false;
	}

	public static isTemporarilyNotAvailable(err: any): boolean {
		if (err instanceof RemoteAuthorityResolverError) {
			return err._code === RemoteAuthorityResolverErrorCode.TemporarilyNotAvailable;
		}
		return false;
	}

	public readonly _message: string | undefined;
	public readonly _code: RemoteAuthorityResolverErrorCode;
	public readonly _detail: any;

	constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) {
		super(message);

		this._message = message;
		this._code = code;
		this._detail = detail;

		// workaround when extending builtin objects and when compiling to ES5, see:
		// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
		if (typeof (<any>Object).setPrototypeOf === 'function') {
			(<any>Object).setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
		}
	}
}

export interface IRemoteAuthorityResolverService {

	_serviceBrand: any;

	resolveAuthority(authority: string): Promise<ResolvedAuthority>;

	clearResolvedAuthority(authority: string): void;
	setResolvedAuthority(resolvedAuthority: ResolvedAuthority): void;
	setResolvedAuthorityError(authority: string, err: any): void;
}
<commit_msg>The TemporarilyNotAvailable error should be considered handled<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

export const IRemoteAuthorityResolverService = createDecorator<IRemoteAuthorityResolverService>('remoteAuthorityResolverService');

export interface ResolvedAuthority {
	readonly authority: string;
	readonly host: string;
	readonly port: number;
}

export enum RemoteAuthorityResolverErrorCode {
	Unknown = 'Unknown',
	NotAvailable = 'NotAvailable',
	TemporarilyNotAvailable = 'TemporarilyNotAvailable',
}

export class RemoteAuthorityResolverError extends Error {

	public static isHandledNotAvailable(err: any): boolean {
		if (err instanceof RemoteAuthorityResolverError) {
			if (err._code === RemoteAuthorityResolverErrorCode.NotAvailable && err._detail === true) {
				return true;
			}
		}

		return this.isTemporarilyNotAvailable(err);
	}

	public static isTemporarilyNotAvailable(err: any): boolean {
		if (err instanceof RemoteAuthorityResolverError) {
			return err._code === RemoteAuthorityResolverErrorCode.TemporarilyNotAvailable;
		}
		return false;
	}

	public readonly _message: string | undefined;
	public readonly _code: RemoteAuthorityResolverErrorCode;
	public readonly _detail: any;

	constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) {
		super(message);

		this._message = message;
		this._code = code;
		this._detail = detail;

		// workaround when extending builtin objects and when compiling to ES5, see:
		// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
		if (typeof (<any>Object).setPrototypeOf === 'function') {
			(<any>Object).setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
		}
	}
}

export interface IRemoteAuthorityResolverService {

	_serviceBrand: any;

	resolveAuthority(authority: string): Promise<ResolvedAuthority>;

	clearResolvedAuthority(authority: string): void;
	setResolvedAuthority(resolvedAuthority: ResolvedAuthority): void;
	setResolvedAuthorityError(authority: string, err: any): void;
}

{'fraction_non_alphanumeric': 0.161128903122498, 'fraction_numerical': 0.00040032025620496394, 'mean_word_length': 3.8280193236714974, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4261165', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1287, 'n_words': 310}