Skip to content

Commit 2b45629

Browse files
authored
🔀 Merge pull request #48 from MrSkwiggs/bleeding_edge
📄 Improve error logs
2 parents 8766031 + 9cc5084 commit 2b45629

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Sources/Netswift/Core/NetswiftError/NetswiftError.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ extension NetswiftError: CustomDebugStringConvertible {
7474
description = "The response returned by the server does not conform to expected type"
7575
case .noResponseError:
7676
description = "The response returned by the server is empty / nil"
77-
case .responseDecodingError:
78-
description = "The response's raw data could not be understood"
77+
case let .responseDecodingError(decodingError):
78+
description = decodingError.fullDescription
7979
case .responseCastingError:
8080
description = "The response could not be casted to the Request's IncomingType"
8181
case .notAuthenticated:
@@ -101,7 +101,7 @@ extension NetswiftError: CustomDebugStringConvertible {
101101
}
102102

103103
return """
104-
Netswift Error: \(description)
104+
\(description)
105105
106106
Payload:
107107
\(payload?.prettyPrinted ?? "None")
@@ -127,3 +127,20 @@ private extension Data {
127127
}
128128
}
129129
}
130+
131+
private extension DecodingError {
132+
var fullDescription: String {
133+
switch self {
134+
case .typeMismatch(let any, let context):
135+
return context.debugDescription
136+
case .valueNotFound(let any, let context):
137+
return context.debugDescription
138+
case .keyNotFound(let codingKey, let context):
139+
return context.debugDescription
140+
case .dataCorrupted(let context):
141+
return context.debugDescription
142+
@unknown default:
143+
return "Unknown default decoding error"
144+
}
145+
}
146+
}

0 commit comments

Comments
 (0)