Skip to content

Commit

Permalink
Add convenience methods to check for predefined errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shoumikhin committed May 22, 2018
1 parent 2780035 commit ba91f23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/FBLPromises/include/FBLPromiseError.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
8 changes: 4 additions & 4 deletions Sources/Promises/PromiseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down

0 comments on commit ba91f23

Please sign in to comment.