@@ -3,47 +3,28 @@ import Foundation
3
3
open class BaseError : Error , LocalizedError , CustomStringConvertible {
4
4
public let file : StaticString
5
5
public let line : UInt
6
-
7
- // Properties for LocalizedError conformance
6
+
8
7
public var errorDescription : String ?
9
8
public var failureReason : String ?
10
- public var recoverySuggestion : String ? // Optional
11
- public var helpAnchor : String ? // Optional
12
-
13
- // Store the original components for constructing descriptions
9
+ public var recoverySuggestion : String ?
10
+ public var helpAnchor : String ?
11
+
14
12
private let providedMessage : String
15
- private let errorTypeString : String // This was the 'error' parameter in your init
16
-
17
- // This is for CustomStringConvertible.
18
- // XCTest might use this when an error is thrown out of a test method.
13
+ private let errorTypeString : String
14
+
19
15
public var description : String {
20
- // We'll make this the same as errorDescription for consistency,
21
- // ensuring a detailed message is available.
22
16
return self . errorDescription ?? " Undefined error: \( self . errorTypeString) - \( self . providedMessage) "
23
17
}
24
-
25
- // 'error' parameter here is a string describing the category or type of the error.
18
+
26
19
public init ( message: String , error: String , file: StaticString = #file, line: UInt = #line) {
27
20
self . file = file
28
21
self . line = line
29
22
self . providedMessage = message
30
23
self . errorTypeString = error
31
-
24
+
32
25
let fileName = URL ( fileURLWithPath: String ( describing: file) ) . lastPathComponent
33
26
34
- // Populate LocalizedError properties
35
- // This self.errorDescription will be used by error.localizedDescription
36
27
self . errorDescription = " \( self . errorTypeString) : \( self . providedMessage) (at \( fileName) : \( line) ) "
37
-
38
28
self . failureReason = " An issue occurred related to ' \( self . errorTypeString) '. "
39
29
}
40
30
}
41
-
42
- // Your ConfigurationError.setup class remains the same:
43
- // open class ConfigurationError {
44
- // public final class setup: BaseError {
45
- // public init(message: String, file: StaticString = #file, line: UInt = #line) {
46
- // super.init(message: message, error: "Configuration error", file: file, line: line)
47
- // }
48
- // }
49
- // }
0 commit comments