     
     case responseValidationFailed(reason: ResponseFailureReason)
     case persistanceValidationFailed(reason: PersistanceFailureReason)
+    
 }
 
 extension MSError.ResponseFailureReason {
     var responseCode: Int {
         switch self {
-        case .tokenExpired(let code),.badRequest(let code):
+        case .tokenExpired(let code):
             return code
+        case .badRequest(let error):
+            return (error as NSError).code
         case .internalServerError:
             return 500
         default:
             return 0
         }
     }
+    
+    var underlyingError: Error? {
+        switch self {
+        case .badRequest(let error):
+            return error
+        default:
+            return nil
+        }
+    }
+    
     var hasTokenExpired: Bool {
         switch self {
         case .tokenExpired( _):

            return reason.responseCode
        default:
            return 0
        }
    }
    

            return false
        }
    }
    init(code:Int, error:Error) {
        switch code {
        case 401:
            self = .tokenExpired(code: code)
