From 1263a5e84113b10eb94c986f959dbe7f2dbe0141 Mon Sep 17 00:00:00 2001 From: Andrea Prearo Date: Sun, 30 Apr 2017 13:42:33 -0700 Subject: [PATCH] Clean up DataWriterError Changes: - Alphabetize error cases for DataWriterError. --- Clue/Classes/Writers/DataWriterError.swift | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Clue/Classes/Writers/DataWriterError.swift b/Clue/Classes/Writers/DataWriterError.swift index a282516..8f1ce1f 100644 --- a/Clue/Classes/Writers/DataWriterError.swift +++ b/Clue/Classes/Writers/DataWriterError.swift @@ -10,25 +10,34 @@ import Foundation /// An error that can be returned from a `DataWriter` instance. /// +/// - error: Internal error. +/// - failure: Internal failure. +/// - invalidData: Invalid data. +/// - invalidJSON: Invalid JSON content. /// - unknown: Unknown error. -/// - invalidObject: Invalid JSON content. -/// - failure: internal failure. public enum DataWriterError: Error { - case unknown + case error(Error) + case failure(NSError) case invalidData(Data) case invalidJSON(Any) - case failure(NSError) - case error(Error) + case unknown } extension DataWriterError: Equatable {} public func == (lhs: DataWriterError, rhs: DataWriterError) -> Bool { switch lhs { - case .unknown: + case .error(let error): switch rhs { - case .unknown: - return true + case .error(let error2): + return String(describing: error) == String(describing: error2) + default: + return false + } + case .failure(let error): + switch rhs { + case .failure(let error2): + return error == error2 default: return false } @@ -46,17 +55,10 @@ public func == (lhs: DataWriterError, rhs: DataWriterError) -> Bool { default: return false } - case .failure(let error): - switch rhs { - case .failure(let error2): - return error == error2 - default: - return false - } - case .error(let error): + case .unknown: switch rhs { - case .error(let error2): - return String(describing: error) == String(describing: error2) + case .unknown: + return true default: return false }