// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

//! Error types for LDAP operations.

use thiserror::Error;

/// Configuration validation errors.
#[non_exhaustive]
#[derive(Error, Debug, PartialEq, Eq)]
pub enum ConfigError {
    /// LDAP server URL was not provided.
    #[error("LDAP server URL is required")]
    MissingServerUrl,

    /// Bind DN was not provided.
    #[error("LDAP bind DN is required")]
    MissingBindDn,

    /// Bind password was not provided.
    #[error("LDAP bind password is required")]
    MissingBindPassword,

    /// Search base was not provided.
    #[error("LDAP search base is required")]
    MissingSearchBase,

    /// Provided server URL is not a valid URL.
    #[error("LDAP search filter is required")]
    MissingSearchFilter,
}

/// Errors from LDAP authentication operations.
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum LdapError {
    /// The HTTP request to the LDAP service failed.
    #[error("LDAP service request failed: {0}")]
    RequestFailed(String),

    /// The LDAP server returned an error response.
    #[error("LDAP Server Failure")]
    ServerError,

    /// Authentication was rejected (invalid credentials).
    #[error("Authentication Attempt Failed")]
    AuthenticationFailed,
}
