Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace FileSystemError with CocoaError
  • Loading branch information
MaxDesiatov committed Aug 2, 2023
commit ea5bccbda801e2f3155e99f26ef414fb2f4e5194
1 change: 0 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ let package = Package(
.target(
name: "SwiftDocCTestUtilities",
dependencies: [
"SwiftDocC",
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDocC/Indexing/Navigator/NavigatorIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class NavigatorIndex {

public var errorDescription: String {
switch self {
case .missingBundleIdentifier:
case .missingBundleIdentifier, .missingBundleIndentifier:
return "A navigator index requires a bundle identifier, which is missing."
case .missingTitle:
return "The page has no valid title available."
Expand Down Expand Up @@ -174,7 +174,7 @@ public class NavigatorIndex {
let availabilityIndexFileURL = url.appendingPathComponent("availability.index", isDirectory: false)
let availabilityIndexFileHandle = try FileHandle(forReadingFrom: availabilityIndexFileURL)
guard let data = try availabilityIndexFileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: availabilityIndexFileURL.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": availabilityIndexFileURL.path])
}
let plistDecoder = PropertyListDecoder()
let availabilityIndex = try plistDecoder.decode(AvailabilityIndex.self, from: data)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Indexing/Navigator/NavigatorTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public class NavigatorTree {
}

guard let data = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": path])
}

var map = [UInt32: Node]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct LocalFileSystemDataProvider: DocumentationWorkspaceDataProvider, F
precondition(url.isFileURL, "Unexpected non-file url '\(url)'.")
let fileHandle = try FileHandle(forReadingFrom: url)
guard let data = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: url.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": url.path])
}

return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct PrebuiltLocalFileSystemDataProvider: DocumentationWorkspaceDataPro
precondition(url.isFileURL, "Unexpected non-file url '\(url)'.")
let fileHandle = try FileHandle(forReadingFrom: url)
guard let data = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: url.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": url.path])
}

return data
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Servers/FileServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class FileServer {
*/
@available(*, deprecated, message: "Use 'data(for path: String)' instead.")
public func data(for url: URL) -> Data? {
return data(for url.path)
return data(for: url.path)
}

public func data(for path: String) -> Data? {
Expand Down
21 changes: 0 additions & 21 deletions Sources/SwiftDocC/Utility/Errors/FileSystemError.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/SwiftDocCTestUtilities/FilesAndFolders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public struct CopyOfFile: File, DataRepresentable {
guard FileManager.default.fileExists(atPath: original.path, isDirectory: &isDirectory), !isDirectory.boolValue else { throw Error.notAFile(original) }
let fileHandle = try FileHandle(forReadingFrom: original)
guard let data = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: original.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": original.path])
}
return data
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct DefaultRequestHandler: RequestHandlerFactory {
let fileURL = self.rootURL.appendingPathComponent("index.html")
let fileHandle = try FileHandle(forReadingFrom: fileURL)
guard let response = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: fileURL.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": fileURL.path])
}

var content = context.channel.allocator.buffer(capacity: response.count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct FileRequestHandler: RequestHandlerFactory {
do {
let fileHandle = try FileHandle(forReadingFrom: fileURL)
guard let readData = try fileHandle.readToEnd() else {
throw FileSystemError.noDataReadFromFile(path: fileURL.path)
throw CocoaError(.fileReadUnknown, userInfo: ["path": fileURL.path])
}
data = readData
totalLength = data.count
Expand Down