- iOS Programming Cookbook
- Hossam Ghareeb
- 101字
- 2021-07-09 18:29:45
Multiple catch statements
In the preceding example, you will notice that we've created a catch statement, and inside, we used a switch statement to cover all cases of error. This is a correct way, but for your reference, we have another way to do this. Consider the following:
catch SignUpUserError.InvalidFirstOrLastName{ } catch SignUpUserError.InvalidEmail{ } catch SignUpUserError.WeakPassword{ } catch SignUpUserError.PasswordsDontMatch{ }
After the do statement, you can list catch statement with the type of error that this statement will catch. Using this method has a condition that the catch statements should be exhaustive, which means it should cover all types of errors.
推薦閱讀
- Linux運維之道(第3版)
- WordPress Mobile Web Development:Beginner's Guide
- 精通Linux內核開發
- 混沌工程:復雜系統韌性實現之道
- Windows Server 2012網絡操作系統企業應用案例詳解
- 數據中心系統工程及應用
- Learning Magento 2 Administration
- Windows 8實戰從入門到精通(超值版)
- Red Hat Enterprise Linux 6.4網絡操作系統詳解
- Introduction to R for Quantitative Finance
- Windows 7使用詳解(修訂版)
- Linux集群之美
- iOS Programming Cookbook
- UNIX傳奇:歷史與回憶
- Windows 11使用方法與技巧從入門到精通