Middleware and functions to deal simply with client errors.

General mechanism for creating and returning client 40x errors to callers.