Skip to content

Commit 8148c63

Browse files
committed
Add MacroError.errorDescription
1 parent 0644be1 commit 8148c63

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Sources/CoreModelMacros/Error.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,32 @@
55
// Created by Alsey Coleman Miller on 6/17/25.
66
//
77

8+
import Foundation
9+
810
enum MacroError: Error {
911

12+
/// The provided type is invalid.
1013
case invalidType
14+
15+
/// Unknown attribute type
1116
case unknownAttributeType(for: String)
17+
18+
/// Unknown inverse relationship
1219
case unknownInverseRelationship(for: String)
1320
}
21+
22+
#if canImport(Darwin)
23+
extension MacroError: LocalizedError {
24+
25+
var errorDescription: String? {
26+
switch self {
27+
case .invalidType:
28+
return NSLocalizedString("The provided type is invalid.", comment: "Invalid type error")
29+
case .unknownAttributeType(let type):
30+
return String(format: NSLocalizedString("Unknown attribute type: %@", comment: "Unknown attribute type error"), type)
31+
case .unknownInverseRelationship(let relationship):
32+
return String(format: NSLocalizedString("Unknown inverse relationship for: %@", comment: "Unknown inverse relationship error"), relationship)
33+
}
34+
}
35+
}
36+
#endif

0 commit comments

Comments
 (0)