In model/business logic returning collections, returning nonoptional collection types simplifies consumer logic, and throwing errors clearly communicates failure modes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func modelLayerFunction() throws -> [Any] { /* ... */ } | |
func controllerFunction() throws -> [Any] { | |
let models = try modelLayerFunction() | |
// ... | |
return models | |
} | |
do { | |
let results = try controllerFunction() | |
// work with result | |
} catch { | |
// log error and/or show alert | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment