2015-08-21 13:02:36 +00:00
|
|
|
//
|
|
|
|
// Error.swift
|
|
|
|
// mas-cli
|
|
|
|
//
|
|
|
|
// Created by Andrew Naylor on 21/08/2015.
|
|
|
|
// Copyright (c) 2015 Andrew Naylor. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2015-08-24 18:44:47 +00:00
|
|
|
public let MASErrorDomain: String = "MASErrorDomain"
|
|
|
|
|
|
|
|
private let MASErrorSource: String = "MASErrorSource"
|
|
|
|
|
|
|
|
public enum MASErrorCode: Int {
|
2016-09-17 12:58:38 +00:00
|
|
|
case noError
|
|
|
|
case notSignedIn
|
|
|
|
case purchaseError
|
|
|
|
case noDownloads
|
|
|
|
case cancelled
|
|
|
|
case downloadFailed
|
|
|
|
case signInError
|
|
|
|
case alreadySignedIn
|
|
|
|
case searchError
|
|
|
|
case noSearchResultsFound
|
|
|
|
case noUpdatesFound
|
2015-08-24 18:44:47 +00:00
|
|
|
|
|
|
|
var exitCode: Int32 {
|
|
|
|
return Int32(self.rawValue)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-17 15:33:50 +00:00
|
|
|
open class MASError: Error {
|
2016-09-17 12:58:38 +00:00
|
|
|
let code: MASErrorCode
|
2015-08-24 18:44:47 +00:00
|
|
|
|
2016-09-17 12:58:38 +00:00
|
|
|
let sourceError: NSError?
|
2015-09-03 23:38:54 +00:00
|
|
|
|
2016-09-17 12:58:38 +00:00
|
|
|
init(code: MASErrorCode, sourceError: NSError? = nil) {
|
|
|
|
self.code = code
|
|
|
|
self.sourceError = sourceError
|
2015-08-21 13:02:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public func == (lhs: MASError, rhs: MASError) -> Bool {
|
|
|
|
return false
|
2016-09-17 12:58:38 +00:00
|
|
|
}
|