diff --git a/Sources/YData/Core/Error/FabricError.swift b/Sources/YData/Core/Error/FabricError.swift new file mode 100644 index 0000000..c39a10a --- /dev/null +++ b/Sources/YData/Core/Error/FabricError.swift @@ -0,0 +1,13 @@ +import Foundation + +public protocol FabricError: Error, Codable { + var context: [String: String]? { get } + var description: String { get } + var httpCode: Int? { get } + var name: String { get } + var returnValue: Int { get } +} + +public extension FabricError { + var name: String { "\(Self.self)" } +} diff --git a/Sources/YData/Core/Error/GenericFabricError.swift b/Sources/YData/Core/Error/GenericFabricError.swift new file mode 100644 index 0000000..976b3cc --- /dev/null +++ b/Sources/YData/Core/Error/GenericFabricError.swift @@ -0,0 +1,33 @@ +import Foundation + +public class GenericFabricError: FabricError { + public var context: [String: String]? + public var description: String + public var httpCode: Int? + var _name: String? // swiftlint:disable:this identifier_name + public var returnValue: Int + + public var name: String { + get { + _name ?? "\(Self.self)" + } + + set { + _name = newValue + } + } + + init( + context: [String: String]? = nil, + description: String, + httpCode: Int? = nil, + name: String? = nil, + returnValue: Int + ) { + self.context = context + self.description = description + self.httpCode = httpCode + self._name = name + self.returnValue = returnValue + } +}