Raise error if unknown mode is given to with_connection