This is Understanding Combine, written by Matt Neuburg. It is a work in progress. Corrections and suggestions are greatly appreciated (you can comment here). So are donations; please consider keeping me going by funding this work at http://www.paypal.me/mattneub. Or buy my books: the current editions are iOS 13 Programming Fundamentals with Swift and Programming iOS 13. Thank you!


Error Handlers

Error Handlers
By error handlers I mean those operators that do for errors — meaning failures — what operators such as .map and .filter do for values. Both values and failures are objects that come down the pipeline, and each has a type; and just as you can transform one value into another, and even into a different type of value, or prevent a value from moving further down the pipeline, it is perfectly reasonable to want to do the same sort of thing for failures.

The error handler par excellence is .mapError, which does just what .map does, but for errors: if it receives a failure from upstream, it can send downstream a failure containing a different error object, even a different type of error object.


Table of Contents