Skip to content

Commit 7bfc4b2

Browse files
author
“Akshay
committed
MOB-9192 - Passing in error under 401
Removing the generic error mapping at Request Handling layer. This is what gets read further and appropriate AuthFailure reasons will be passed to the app.
1 parent f626340 commit 7bfc4b2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

swift-sdk/Internal/NetworkHelper.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ struct NetworkHelper {
156156
if httpStatusCode >= 500 {
157157
return .failure(NetworkError(reason: "Internal Server Error", data: data, httpStatusCode: httpStatusCode))
158158
} else if httpStatusCode >= 400 {
159+
160+
if let data = data,
161+
let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
162+
let msg = json["msg"] as? String {
163+
return .failure(NetworkError(reason: msg, data: data, httpStatusCode: httpStatusCode))
164+
}
159165
return .failure(NetworkError(reason: "Invalid Request", data: data, httpStatusCode: httpStatusCode))
160166
} else if httpStatusCode == 200 {
161167
if let data = data, data.count > 0 {

0 commit comments

Comments
 (0)