Added error handling in auth_result.