Skip to content

Commit 1de68c5

Browse files
add logging to DocCReferenceResolutionService
1 parent f77e323 commit 1de68c5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Sources/DocCDocumentation/DocCReferenceResolutionService.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import Foundation
1414
import IndexStoreDB
1515
import LanguageServerProtocol
16+
import SKLogging
1617
import SemanticIndex
1718
@_spi(Linkcompletion) @preconcurrency import SwiftDocC
1819
import SwiftExtensions
@@ -48,7 +49,7 @@ final class DocCReferenceResolutionService: DocumentationService, Sendable {
4849
) {
4950
do {
5051
let response = try process(message)
51-
completion(response);
52+
completion(response)
5253
} catch {
5354
completion(createResponseWithErrorMessage(error.localizedDescription))
5455
}
@@ -120,7 +121,7 @@ final class DocCReferenceResolutionService: DocumentationService, Sendable {
120121
}
121122
}
122123

123-
private func decode<T>(_ type: T.Type, from data: Data) throws(ReferenceResolutionError) -> T where T: Decodable {
124+
private func decode<T: Decodable>(_ type: T.Type, from data: Data) throws(ReferenceResolutionError) -> T {
124125
do {
125126
return try JSONDecoder().decode(T.self, from: data)
126127
} catch {
@@ -138,12 +139,10 @@ final class DocCReferenceResolutionService: DocumentationService, Sendable {
138139

139140
private func createResponseWithErrorMessage(_ message: String) -> DocumentationServer.Message {
140141
let errorMessage = OutOfProcessReferenceResolver.Response.errorMessage(message)
141-
do {
142-
let encodedErrorMessage = try JSONEncoder().encode(errorMessage)
143-
return createResponse(payload: encodedErrorMessage)
144-
} catch {
145-
return createResponse(payload: nil)
142+
let encodedErrorMessage = orLog("Encoding error message for OutOfProcessReferenceResolver.Response") {
143+
try JSONEncoder().encode(errorMessage)
146144
}
145+
return createResponse(payload: encodedErrorMessage)
147146
}
148147

149148
private func createResponse(payload: Data?) -> DocumentationServer.Message {

0 commit comments

Comments
 (0)