Error message is not great here. Is there a better way to do this?