Looking here: https://www.htmlunit.org/apidocs/org/htmlunit/WebClientOptions.html
I can see WebClientOptions.setThrowExceptionOnFailingStatusCode (so just a rename).
WebClientOptions.setThrowExceptionOnFailingStatusCode