Catches the exact error in expect