iOS Error Handling in Swift Error Handling Throwing Errors

From inside the body of the function, throw an error using the error object and single member provided.

Im not sure on what to do here

error.swift
enum BookError: Error {
  case incorrectTitle
}

func lend() throws {

}

1 Answer

Christian Mangeng
Christian Mangeng
15,963 Points

Hi diegoarenas,

you now need to throw the error you defined in the enum (consisting of the object BookError and the member incorrectTitle):

func lend() throws {
    throw BookError.incorrectTitle
}