fix rest client so it correctly displays error when request fails