From ba91f236053a22d5a150f2e6df8854034188e079 Mon Sep 17 00:00:00 2001 From: Anthony Shoumikhin Date: Tue, 22 May 2018 14:12:34 -0700 Subject: [PATCH] Add convenience methods to check for predefined errors --- Sources/FBLPromises/include/FBLPromiseError.h | 2 +- Sources/Promises/PromiseError.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/FBLPromises/include/FBLPromiseError.h b/Sources/FBLPromises/include/FBLPromiseError.h index 8566a6b..d0d47e9 100644 --- a/Sources/FBLPromises/include/FBLPromiseError.h +++ b/Sources/FBLPromises/include/FBLPromiseError.h @@ -23,7 +23,7 @@ extern NSErrorDomain const FBLPromiseErrorDomain NS_REFINED_FOR_SWIFT; /** Possible error codes in `FBLPromiseErrorDomain`. */ -typedef NS_ERROR_ENUM(FBLPromiseErrorDomain, FBLPromiseErrorCode) { +typedef NS_ENUM(NSInteger, FBLPromiseErrorCode) { /** Promise failed to resolve in time. */ FBLPromiseErrorCodeTimedOut = 1, /** Validation predicate returned false. */ diff --git a/Sources/Promises/PromiseError.swift b/Sources/Promises/PromiseError.swift index 226046c..37f0d04 100644 --- a/Sources/Promises/PromiseError.swift +++ b/Sources/Promises/PromiseError.swift @@ -28,9 +28,9 @@ extension PromiseError { let error = error as NSError if error.domain != __FBLPromiseErrorDomain { return nil } switch error.code { - case __FBLPromiseError.timedOut.rawValue: + case __FBLPromiseErrorCode.timedOut.rawValue: self = .timedOut - case __FBLPromiseError.validationFailure.rawValue: + case __FBLPromiseErrorCode.validationFailure.rawValue: self = .validationFailure default: return nil @@ -46,9 +46,9 @@ extension PromiseError: CustomNSError { public var errorCode: Int { switch self { case .timedOut: - return __FBLPromiseError.timedOut.rawValue + return __FBLPromiseErrorCode.timedOut.rawValue case .validationFailure: - return __FBLPromiseError.validationFailure.rawValue + return __FBLPromiseErrorCode.validationFailure.rawValue } }