import Foundation

struct StorageError {

    let date: Date

    let message: String

    init(date: Date = .now, message: String) {
        self.date = date
        self.message = message
    }
}

extension StorageError: Identifiable {

    var id: String {
        date.description + message
    }
}

extension StorageError: Comparable {

    static func < (lhs: StorageError, rhs: StorageError) -> Bool {
        guard lhs.date == rhs.date else {
            return lhs.date < rhs.date
        }
        return lhs.message < rhs.message
    }
}

extension StorageError: ExpressibleByStringLiteral {

    init(stringLiteral value: StringLiteralType) {
        self.init(message: value)
    }
}
