Files
sourcekit-lsp/Sources/DocCDocumentation/DoccDocumentationError.swift
Matthew Bastien b4e5d8995b Merge pull request #2198 from matthewbastien/docc-swift-symbols
Always try to render some documentation for Swift files
2025-07-16 10:03:04 -04:00

41 lines
1.4 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
package import LanguageServerProtocol
package enum DocCDocumentationError: LocalizedError {
case unsupportedLanguage(Language)
case noDocumentableSymbols
case indexNotAvailable
case symbolNotFound(String)
var errorDescription: String? {
switch self {
case .unsupportedLanguage(let language):
return "Documentation preview is not available for \(language.description) files"
case .noDocumentableSymbols:
return "No documentable symbols were found in this Swift file"
case .indexNotAvailable:
return "The index is not availble to complete the request"
case .symbolNotFound(let symbolName):
return "Could not find symbol \(symbolName) in the project"
}
}
}
package extension ResponseError {
static func requestFailed(doccDocumentationError: DocCDocumentationError) -> ResponseError {
return ResponseError.requestFailed(doccDocumentationError.localizedDescription)
}
}