Raise errors for adapter responses

Any 4xx or 5xx response code from the adapter will result in an error being raised.
Add global error handler

Ensures that any errors raised in the agent are logged and returned consistently.