client: correctly handle exceptions on error status codes