improve error handling with NewHTTPError