This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func divide(x: Float, _ y: Float) throws -> Float { | |
guard x != 0 else { | |
throw DivisionErrorEnum.DividendIsZero(message: "You’re trying to divide 0") | |
} | |
guard y != 0 else { | |
throw DivisionErrorEnum.DivisorIsZero(message: "You’re trying to divide \(x) by 0") | |
} | |
return x/y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DivisionErrorEnum: ErrorType { | |
case DividendIsZero(message: String) | |
case DivisorIsZero(message: String) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum MyError: ErrorType { | |
case AnError, | |
case AnotherError(message: String) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ErrorType { | |
var _domain: Swift.String { get } | |
var _code: Swift.Int { get } | |
} | |
extension ErrorType { | |
public var _domain: String { | |
return String(reflecting: self.dynamicType) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol ErrorType {} | |
extension ErrorType {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestCaseRun.h | |
SENTEST_EXPORT NSString * const SenTestCaseDidStartNotification; | |
SENTEST_EXPORT NSString * const SenTestCaseDidStopNotification; | |
SENTEST_EXPORT NSString * const SenTestCaseDidFailNotification; | |
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestDistributedNotifier.h | |
SENTEST_EXPORT NSString * const SenTestNotificationIdentifierKey; | |
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestSuiteRun.h | |
SENTEST_EXPORT NSString * const SenTestSuiteDidStartNotification; |
NewerOlder