Skip to content

Commit b5620ad

Browse files
committed
Don’t accidentally trump Swift.Error during usage
Refs mxcl/PromiseKit#553
1 parent 61bd563 commit b5620ad

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Sources/UIImagePickerController+Promise.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension UIViewController {
3030
if let img = info[UIImagePickerControllerOriginalImage] as? UIImage {
3131
return img
3232
}
33-
throw Error.noImageFound
33+
throw PMKError.noImageFound
3434
}.always {
3535
vc.presentingViewController?.dismiss(animated: animated, completion: nil)
3636
}
@@ -63,14 +63,14 @@ extension UIViewController {
6363
}
6464

6565
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
66-
reject(UIImagePickerController.Error.cancelled)
66+
reject(UIImagePickerController.PMKError.cancelled)
6767
retainCycle = nil
6868
}
6969
}
7070

7171
extension UIImagePickerController {
7272
/// Errors representing PromiseKit UIImagePickerController failures
73-
public enum Error: CancellableError {
73+
public enum PMKError: CancellableError {
7474
/// The user cancelled the UIImagePickerController.
7575
case cancelled
7676
/// - Returns: true

Sources/UIViewController+Promise.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import PromiseKit
2121
*/
2222
extension UIViewController {
2323

24-
public enum Error: Swift.Error {
24+
public enum PMKError: Error {
2525
case navigationControllerEmpty
2626
case noImageFound
2727
case notPromisable
@@ -43,7 +43,7 @@ extension UIViewController {
4343

4444
switch vc {
4545
case let nc as UINavigationController:
46-
guard let vc = nc.viewControllers.first else { return Promise(error: Error.navigationControllerEmpty) }
46+
guard let vc = nc.viewControllers.first else { return Promise(error: PMKError.navigationControllerEmpty) }
4747
pvc = vc
4848
default:
4949
pvc = vc
@@ -52,13 +52,13 @@ extension UIViewController {
5252
let promise: Promise<T>
5353

5454
if !(pvc is Promisable) {
55-
promise = Promise(error: Error.notPromisable)
55+
promise = Promise(error: PMKError.notPromisable)
5656
} else if let p = pvc.value(forKeyPath: "promise") as? Promise<T> {
5757
promise = p
5858
} else if let _ = pvc.value(forKeyPath: "promise") {
59-
promise = Promise(error: Error.notGenericallyPromisable)
59+
promise = Promise(error: PMKError.notGenericallyPromisable)
6060
} else {
61-
promise = Promise(error: Error.nilPromisable)
61+
promise = Promise(error: PMKError.nilPromisable)
6262
}
6363

6464
if !promise.isPending {

Tests/TestUIViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class UIViewControllerTests: XCTestCase {
1212
let ex = expectation(description: "")
1313
let p: Promise<Int> = rootvc.promise(UIViewController(), animate: [])
1414
p.catch { error in
15-
if case UIViewController.Error.notPromisable = error {
15+
if case UIViewController.PMKError.notPromisable = error {
1616
ex.fulfill()
1717
}
1818
}
@@ -23,7 +23,7 @@ class UIViewControllerTests: XCTestCase {
2323
let ex = expectation(description: "")
2424
let p: Promise<Int> = rootvc.promise(MockViewController(), animate: [])
2525
p.catch { error in
26-
if case UIViewController.Error.nilPromisable = error {
26+
if case UIViewController.PMKError.nilPromisable = error {
2727
ex.fulfill()
2828
}
2929
}
@@ -36,7 +36,7 @@ class UIViewControllerTests: XCTestCase {
3636
my.promise = Promise(value: true)
3737
let p: Promise<Int> = rootvc.promise(my, animate: [])
3838
p.catch { err in
39-
if case UIViewController.Error.notGenericallyPromisable = err {
39+
if case UIViewController.PMKError.notGenericallyPromisable = err {
4040
ex.fulfill()
4141
}
4242
}

0 commit comments

Comments
 (0)