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

    
    case responseValidationFailed(reason: ResponseFailureReason)
    case persistanceValidationFailed(reason: PersistanceFailureReason)
}

extension MSError.ResponseFailureReason {
    var responseCode: Int {
        switch self {
        case .tokenExpired(let code),.badRequest(let code):
            return code
        case .internalServerError:
            return 500
        default:
            return 0
        }
    }
    var hasTokenExpired: Bool {
        switch self {
        case .tokenExpired( _):

            return reason.responseCode
        default:
            return 0
        }
    }
    
    /// The `Error` returned by a system framework associated with a `.responseValidationFailed`
    public var underlyingError: Error? {
        switch self {
        case .responseValidationFailed(let reason):
            return reason.underlyingError
        default:
            return nil
        }
    }
    
