You might find this link helpful as an example close to what you are trying to do I think:
https://www.hackingwithswift.com/example-code/language/how-to-use-try-catch-in-swift-to-handle-exceptions
The book "Advanced Swift" has a chapter on error handling, I don't have the other ones handy to compare.
It's worth doing some web searching for blog/medium articles about the topic you are focused on. Swift playgrounds can be a useful tool for exploring something in isolation as well.