Swift에서의 throw 처리
함수 선언부
func canThrowAnError() throws {
// this function may or may not throw an error
}
함수 호출부
do {
try canThrowAnError()
// no error was thrown
} catch {
// an error was thrown
}
func canThrowAnError() throws {
// this function may or may not throw an error
}
do {
try canThrowAnError()
// no error was thrown
} catch {
// an error was thrown
}