Change add_error_handling to use a pred rather than status codes

This ticks the third box of #824. It should be reviewed after #833.

This is not yet done. I am starting by only changing the `service_request` (inside `get_request_func`) call site, so that the `request_func` still takes status codes, but internally it uses a predicate. Next step: have the external API also be a predicate.