diff --git a/Libraries/Connect/Interfaces/ConnectError.swift b/Libraries/Connect/Interfaces/ConnectError.swift index 57c8a6b9..e3d68409 100644 --- a/Libraries/Connect/Interfaces/ConnectError.swift +++ b/Libraries/Connect/Interfaces/ConnectError.swift @@ -47,6 +47,16 @@ public struct ConnectError: Swift.Error { } } + public init( + code: Code, message: String?, exception: Error?, details: [Detail], metadata: Headers + ) { + self.code = code + self.message = message + self.exception = exception + self.details = details + self.metadata = metadata + } + /// Error details are sent over the network to clients, which can then work with /// strongly-typed data rather than trying to parse a complex error message. For /// example, you might use details to send a localized error message or retry @@ -62,6 +72,11 @@ public struct ConnectError: Swift.Error { case type = "type" case payload = "value" } + + public init(type: String, payload: Data?) { + self.type = type + self.payload = payload + } } }