Ordering completion arguments
If you want to support two completion blocks (closures), one for success and one for failure, I suggest ordering them so that the positive one is the last and, if applicable, also make error handling optional:
func execute(_ arguments: Any,
failure: ((_: Any) -> Void)? = nil, success: () -> Void) {
…
}
This way one can write a client like this:
execute(arguments, failure: { details in handle(error: details) }) {
// continue
}
handle(error details: Any) {
…
}
or when there is no need to handle errors (decided after careful analysis :) ):
execute(arguments) {
// continue
}