![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fuiq2W%2FbtszM1YH89p%2Fm2nwF7hEwWAPnNPPeVrTP0%2Fimg.png)
Errors - Throwing Errors, Handling Errors, Results
·
SwiftUI
내가 원하는 에러를 직접 만들어 throw 로 해당 에러를 받을 수 있다enum Errors: Error { case OutOfStock}struct Stock { var totalLamps = 5 mutating func sold(amount: Int) throws { if amount > totalLamps { throw Errors.OutOfStock } else { totalLamps = totalLamps - amount } }}var mystock = Stock() 이제 throws 함수를 만들었으면 해당 throw된 error를 받을 수 있어야한다. 아래 do-catch 로 error를 처리할 수 있다. 하지만 catch ..