Align IllegalStateException with SQLException handling since IllegalState is only handled internally and the public facing Exception remains unchanged in either way.

Closes gh-28258

Comment From: snicoll

Good stuff, thanks @kevin0x90 and @Suthman.

Comment From: kevin0x90

Thanks for accepting our small contribution @snicoll