Skip to content

Commit 8ce16d6

Browse files
authored
Provide all fatalError() a string (#9522)
1 parent af38fe0 commit 8ce16d6

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

Sources/LLBuildManifest/LLBuildManifestWriter.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,63 +129,63 @@ public struct ManifestToolStream {
129129
fileprivate var buffer = ""
130130

131131
public subscript(key: String) -> Int {
132-
get { fatalError() }
132+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an Int") }
133133
set {
134134
self.buffer += " \(key): \(newValue.description.asJSON)\n"
135135
}
136136
}
137137

138138
public subscript(key: String) -> String {
139-
get { fatalError() }
139+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return a String") }
140140
set {
141141
self.buffer += " \(key): \(newValue.asJSON)\n"
142142
}
143143
}
144144

145145
public subscript(key: String) -> ToolProtocol {
146-
get { fatalError() }
146+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return a ToolProtocol") }
147147
set {
148148
self.buffer += " \(key): \(type(of: newValue).name)\n"
149149
}
150150
}
151151

152152
public subscript(key: String) -> AbsolutePath {
153-
get { fatalError() }
153+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an AbsolutePath") }
154154
set {
155155
self.buffer += " \(key): \(newValue.pathString.asJSON)\n"
156156
}
157157
}
158158

159159
public subscript(key: String) -> [AbsolutePath] {
160-
get { fatalError() }
160+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an array of AbsolutePath") }
161161
set {
162162
self.buffer += " \(key): \(newValue.map(\.pathString).asJSON)\n"
163163
}
164164
}
165165

166166
public subscript(key: String) -> [Node] {
167-
get { fatalError() }
167+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an array of Node") }
168168
set {
169169
self.buffer += " \(key): \(newValue.map(\.encodingName).asJSON)\n"
170170
}
171171
}
172172

173173
public subscript(key: String) -> Bool {
174-
get { fatalError() }
174+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return a Bool") }
175175
set {
176176
self.buffer += " \(key): \(newValue.description)\n"
177177
}
178178
}
179179

180180
public subscript(key: String) -> [String] {
181-
get { fatalError() }
181+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an array of String") }
182182
set {
183183
self.buffer += " \(key): \(newValue.asJSON)\n"
184184
}
185185
}
186186

187187
public subscript(key: String) -> [String: String] {
188-
get { fatalError() }
188+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return a [String: String]") }
189189
set {
190190
self.buffer += " \(key):\n"
191191
for (key, value) in newValue.sorted(by: { $0.key < $1.key }) {
@@ -195,7 +195,7 @@ public struct ManifestToolStream {
195195
}
196196

197197
package subscript(key: String) -> Environment {
198-
get { fatalError() }
198+
get { fatalError("\(#file):\(#line) at function \(#function) - Cannot get subscript that return an Environment") }
199199
set {
200200
self.buffer += " \(key):\n"
201201
for (key, value) in newValue.sorted(by: { $0.key < $1.key }) {

Sources/PackageGraph/VersionSetSpecifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ extension VersionSetSpecifier {
254254
case (_, .any):
255255
return .empty
256256
case (.any, _):
257-
fatalError()
257+
fatalError("\(#file):\(#line) - Illegal call of \(#function) on left hand side value of `.any`")
258258
case (.empty, _):
259259
return .empty
260260
case (_, .empty):

Sources/QueryEngine/Query.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ extension HashEncoder: UnkeyedEncodingContainer {
156156
}
157157

158158
func superEncoder() -> any Encoder {
159-
fatalError()
159+
fatalError("\(#file):\(#line) - Illegal call of function \(#function)")
160160
}
161161
}
162162

@@ -272,11 +272,11 @@ extension HashEncoder {
272272
}
273273

274274
mutating func superEncoder() -> any Encoder {
275-
fatalError()
275+
fatalError("\(#file):\(#line) - Illegal call of function \(#function)")
276276
}
277277

278278
mutating func superEncoder(forKey key: K) -> any Encoder {
279-
fatalError()
279+
fatalError("\(#file):\(#line) - Illegal call of function \(#function)")
280280
}
281281

282282
typealias Key = K

Sources/Runtimes/PackageDescription/PackageDependency.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ extension Package {
165165
traits: traits
166166
)
167167
}
168-
168+
169169
convenience init(
170170
name: String?,
171171
location: String,
@@ -181,7 +181,7 @@ extension Package {
181181
traits: traits
182182
)
183183
}
184-
184+
185185
convenience init(
186186
id: String,
187187
requirement: RegistryRequirement,
@@ -1067,7 +1067,7 @@ extension Package.Dependency {
10671067
/// ```swift
10681068
/// .package(id: "scope.name", "1.2.3"..."1.2.6"),
10691069
/// ```
1070-
///
1070+
///
10711071
/// If the package you depend on defines traits, the package manager uses the dependency with its default set of traits.
10721072
///
10731073
/// - Parameters:
@@ -1140,11 +1140,11 @@ extension Package.Dependency {
11401140
extension Package.Dependency {
11411141
@available(*, unavailable, message: "use package(url:exact:) instead")
11421142
public static func package(url: String, version: Version) -> Package.Dependency {
1143-
fatalError()
1143+
fatalError("\(#file):\(#line) - Illegal call of deprecated function \(#function)")
11441144
}
11451145

11461146
@available(*, unavailable, message: "use package(url:_:) instead")
11471147
public static func package(url: String, range: Range<Version>) -> Package.Dependency {
1148-
fatalError()
1148+
fatalError("\(#file):\(#line) - Illegal call of deprecated function \(#function)")
11491149
}
11501150
}

Sources/SPMBuildCore/BuildParameters/BuildParameters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public struct BuildParameters: Encodable {
332332
case .library(.dynamic):
333333
return try dynamicLibraryPath(for: product.name)
334334
case .library(.automatic), .plugin:
335-
fatalError()
335+
fatalError("\(#file):\(#line) - Illegal call of function \(#function) with automatica library and plugin")
336336
case .test:
337337
switch buildSystemKind {
338338
case .native, .xcode:

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public final class PackagePIFBuilder {
403403
case .packageProduct: .packageProduct
404404
case .hostBuildTool: fatalError("Unexpected hostBuildTool type")
405405
@unknown default:
406-
fatalError()
406+
fatalError("Unknown product type: \(pifProductType)")
407407
}
408408
}
409409
}

0 commit comments

Comments
 (0)