Skip to content

Commit 90f5d1c

Browse files
committed
Fix init with Error; add memberwise init
1 parent 0b8e999 commit 90f5d1c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

Sources/ObservableWebSocketClient/Model/Error/CodableError.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,28 @@ import Foundation
1010
/// Defines a `Codable` wrapper for `Error`.
1111
public struct CodableError: Error, Codable, Equatable {
1212
public let errorType: String
13-
public let message: String
13+
public let description: String
14+
public let localizedDescription: String
15+
public let domain: String
16+
public let code: Int
1417

15-
public init(_ error: Error, message: String? = nil) {
18+
public init(_ error: Error) {
1619
self.errorType = String(reflecting: type(of: error))
17-
self.message = message ?? error.localizedDescription
20+
self.description = (error as NSError).description
21+
self.localizedDescription = (error as NSError).localizedDescription
22+
self.domain = (error as NSError).domain
23+
self.code = (error as NSError).code
24+
}
25+
26+
internal init(errorType: String,
27+
description: String,
28+
localizedDescription: String,
29+
domain: String,
30+
code: Int) {
31+
self.errorType = errorType
32+
self.description = description
33+
self.localizedDescription = localizedDescription
34+
self.domain = domain
35+
self.code = code
1836
}
1937
}

0 commit comments

Comments
 (0)