mirror of
https://github.com/helje5/dockSwiftOnARM.git
synced 2025-11-01 06:33:34 +00:00
31 lines
712 B
Swift
31 lines
712 B
Swift
|
|
import Foundation
|
|
|
|
public enum ServiceError: Swift.Error {
|
|
case generic(reason: String)
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case reason = "Reason"
|
|
}
|
|
}
|
|
|
|
extension ServiceError: Encodable {
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
switch self {
|
|
case .generic(reason: let reason):
|
|
try container.encode(reason, forKey: .reason)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ServiceError: CustomStringConvertible {
|
|
public var description: String {
|
|
switch self {
|
|
case .generic(reason: let reason):
|
|
return "Services generic error: \(reason)"
|
|
}
|
|
}
|
|
}
|