             
             // If the number of spaces between date strings is inconsistent, there's no way we can find a formatter to match all of them.
             if let numberOfSpaces = numberOfSpaces, count != numberOfSpaces {
-                return nil
+                throw DateFormatError.emptyDates
             }
             
             numberOfSpaces = count

        
        // This will never happen, but we need to make numberOfSpaces an optional so we can compare it to count above.
        guard let _numberOfSpaces = numberOfSpaces else {
            return nil
        }
        
        var formatters: [DateFormatter] = []


import Foundation

public enum DateFormatError: Error {
    case emptyDates
    case inconsistentFormat
    case unspecified
    case noMatchingFormat
}

fileprivate struct DateFormatterString {
    static let DateComponent1 = "MM-dd-yyyy"
    static let DateComponent2 = "dd-MM-yyyy"
    static let DateComponent3 = "yyyy-MM-dd"
    static let DateComponent4 = "yyyy-dd-MM"
    static let DateComponent5 = "yyyyMMddHHmmssZ"
    static let DateComponent6 = "MMMM d, yyyy"
    
    static let TimeComponent1 = "HH:mm"
    static let TimeComponent2 = "hh:mm a"
