src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts/TextFileEditor/handleSetInputError
class TextFileEditor:	protected handleSetInputError(error: Error, input: FileEditorInput, options: ITextEditorOptions | undefined): void {

		// In case we tried to open a file inside the text editor and the response
		// indicates that this is not a text file, reopen the file through the binary
		// editor.
		if ((<TextFileOperationError>error).textFileOperationResult === TextFileOperationResult.FILE_IS_BINARY) {
			return this.openAsBinary(input, options);
		}

		// Similar, handle case where we were asked to open a folder in the text editor.
		if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_IS_DIRECTORY) {
			this.openAsFolder(input);

			throw new Error(localize('openFolderError', "File is a directory"));
		}

		// Offer to create a file from the error if we have a file not found and the name is valid
		if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND && isValidBasename(basename(input.preferredResource))) {
			throw createErrorWithActions(toErrorMessage(error), {
				actions: [
					toAction({
						id: 'workbench.files.action.createMissingFile', label: localize('createFile', "Create File"), run: async () => {
							await this.textFileService.create([{ resource: input.preferredResource }]);

							return this.editorService.openEditor({
								resource: input.preferredResource,
								options: {
									pinned: true // new file gets pinned by default
								}
							});
						}
					})
				]
			});
		}

		// Otherwise make sure the error bubbles up
		throw error;
	}