Skip to content

Commit 74f624b

Browse files
authored
Remove errors that are never raised anywhere. (#797)
* Remove errors that are never raised anywhere. * Deprecate public error that is never raised.
1 parent ca120e1 commit 74f624b

File tree

6 files changed

+11
-77
lines changed

6 files changed

+11
-77
lines changed

Sources/SwiftDocC/Infrastructure/Bundle Assets/DataAssetManager.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -12,17 +12,6 @@ import Foundation
1212

1313
/// A container for a collection of data. Each data can have multiple variants.
1414
struct DataAssetManager {
15-
enum Error: DescribedError {
16-
case invalidImageAsset(URL)
17-
18-
var errorDescription: String {
19-
switch self {
20-
case .invalidImageAsset(let url):
21-
return "The dimensions of the image at \(url.path.singleQuoted) could not be computed because the file is not a valid image."
22-
}
23-
}
24-
}
25-
2615
var storage = [String: DataAsset]()
2716

2817
// A "file name with no extension" to "file name with extension" index
@@ -113,12 +102,10 @@ struct DataAssetManager {
113102
return (reference: dataReference, traits: traitCollection, metadata: metadata)
114103
}
115104

116-
/**
117-
Registers a collection of data and determines their trait collection.
118-
119-
Data objects which have a file name ending with '~dark' are associated to their light variant.
120-
- Throws: Will throw `Error.invalidImageAsset(URL)` if fails to read the size of an image asset (e.g. the file is corrupt).
121-
*/
105+
106+
/// Registers a collection of data and determines their trait collection.
107+
///
108+
/// Data objects which have a file name ending with '~dark' are associated to their light variant.
122109
mutating func register<Datas: Collection>(data datas: Datas, dataProvider: DocumentationContextDataProvider? = nil, bundle documentationBundle: DocumentationBundle? = nil) throws where Datas.Element == URL {
123110
for dataURL in datas {
124111
let meta = try referenceMetaInformationForDataURL(dataURL, dataProvider: dataProvider, bundle: documentationBundle)

Sources/SwiftDocC/Infrastructure/Workspace/LocalFileSystemDataProvider+BundleDiscovery.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -176,21 +176,3 @@ fileprivate extension Array where Element == FSNode {
176176
return matches
177177
}
178178
}
179-
180-
/// An issue discovering a bundle in a workspace.
181-
enum WorkspaceError: DescribedError {
182-
/// The bundle was missing an Info.plist file.
183-
case missingInfoPlist(url: URL)
184-
/// The root element of the Info.plist file was an array rather than a dictionary.
185-
case notADictionaryAtRoot(url: URL)
186-
187-
/// A plain-text representation of the error.
188-
var errorDescription: String {
189-
switch self {
190-
case .missingInfoPlist(let url):
191-
return "A bundle was found in the workspace at '\(url)' but it was missing an Info.plist."
192-
case .notADictionaryAtRoot(let url):
193-
return "A bundle was found in the workspace but its Info.plist at '\(url)' was not structured correctly: it contained a root array rather than a root dictionary."
194-
}
195-
}
196-
}

Sources/SwiftDocC/Model/Rendering/Variants/RenderNodeVariantOverridesApplier.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -43,11 +43,9 @@ public struct RenderNodeVariantOverridesApplier {
4343
var variantOverrides: VariantOverrides?
4444
}
4545

46-
/// An error that occured while applying overrides in a render node.
46+
@available(*, deprecated, message: "This error is never raised. This deprecated API will be removed after 5.11 is released")
4747
public enum Error: DescribedError {
48-
/// An error indicating that the error node is corrupted or malformed.
4948
case corruptedRenderNode
50-
5149
public var errorDescription: String {
5250
switch self {
5351
case .corruptedRenderNode:

Sources/SwiftDocCUtilities/Action/Actions/Convert/JSONEncodingRenderNodeWriter.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -15,18 +15,6 @@ import SwiftDocC
1515
///
1616
/// The render node writer writes the JSON files into a hierarchy of folders and subfolders based on the relative URL for each node.
1717
class JSONEncodingRenderNodeWriter {
18-
/// Errors that may occur while writing render node JSON files.
19-
enum Error: DescribedError {
20-
/// A file already exist at this path.
21-
case fileExists(String)
22-
/// The absolute path to the file is too long.
23-
public var errorDescription: String {
24-
switch self {
25-
case .fileExists(let path): return "File already exists at: '\(path)'"
26-
}
27-
}
28-
}
29-
3018
private let renderNodeURLGenerator: NodeURLGenerator
3119
private let targetFolder: URL
3220
private let transformForStaticHostingIndexHTML: URL?
@@ -56,7 +44,6 @@ class JSONEncodingRenderNodeWriter {
5644
/// create those intermediate folders before writing the JSON file.
5745
///
5846
/// - Parameter renderNode: The node which the writer object writes to a JSON file.
59-
/// - Throws: A ``Error/fileExists`` error if a file already exists at the location for this node's JSON file.
6047
func write(_ renderNode: RenderNode) throws {
6148
let fileSafePath = NodeURLGenerator.fileSafeReferencePath(
6249
renderNode.identifier,

Sources/SwiftDocCUtilities/Action/Actions/IndexAction.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -13,16 +13,6 @@ import SwiftDocC
1313

1414
/// An action that creates an index of a documentation bundle.
1515
public struct IndexAction: Action {
16-
enum Error: DescribedError {
17-
case doesNotContainBundle(url: URL)
18-
var errorDescription: String {
19-
switch self {
20-
case .doesNotContainBundle(let url):
21-
return "The directory at '\(url)' and its subdirectories do not contain at least one valid documentation bundle. A documentation bundle is a directory ending in `.docc`."
22-
}
23-
}
24-
}
25-
2616
let rootURL: URL
2717
let outputURL: URL
2818
let bundleIdentifier: String

Sources/SwiftDocCUtilities/Action/Actions/PreviewAction.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -37,16 +37,6 @@ public final class PreviewAction: Action, RecreatingContext {
3737
/// A test configuration allowing running multiple previews for concurrent testing.
3838
static var allowConcurrentPreviews = false
3939

40-
enum Error: DescribedError {
41-
case technologyNotFound, cannotConvert
42-
var errorDescription: String {
43-
switch self {
44-
case .technologyNotFound: return "A technology page not found in context."
45-
case .cannotConvert: return "Unable to run documentation conversion."
46-
}
47-
}
48-
}
49-
5040
private let context: DocumentationContext
5141
private let workspace: DocumentationWorkspace
5242
private let printHTMLTemplatePath: Bool

0 commit comments

Comments
 (0)