Catch errors in the API server and pass to client

Catch errors thrown while processing API requests and pass them back
to the originating client.