Fixed a bug where the wrong error message was bubbling up.