0
我有這樣的自定義錯誤類:swift2如何打印錯誤消息在catch
enum RegistrationError :ErrorType{
case PaymentFail
case InformationMissed
case UnKnown
}
我這樣定義一個函數:
func register(studentNationalID: Int) throws -> Int {
// do my business logic then:
if studentNationalID == 100 {
throw RegistrationError.UError(message: "this is cool")
}
if studentNationalID == 10 {
throw RegistrationError.InformationMissed
}
return 0
}
我調用該函數是這樣的:
do{
let s = try register(100)
print("s = \(s)")
} catch RegistrationError.UError {
print("It is error")
}
我的問題是如何打印我拋出異常時拋出的錯誤信息?
我對Swift2