Find a workaround.
Catching the IOException and checking for the error text is one option. There seem to be others which are less brittle.