protected function hideOrThrow(\Exception $e, $hideUserNotFoundExceptions)
    {
        if ($hideUserNotFoundExceptions) {
            throw new BadCredentialsException('Bad credentials.', 0, $e);
        }

        // Specifically show LdapTools related exceptions, ignore others.
        // Custom auth exception messages don't exist until Symfony 2.8, 2.7 is still under support...
        if (!$hideUserNotFoundExceptions && $e instanceof Exception && class_exists('Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException')) {
            throw new CustomUserMessageAuthenticationException($e->getMessage(), [], $e->getCode());
        }

        throw $e;
    }