New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LDAP] Add error codes to exceptions #28677

Open
shanept opened this Issue Oct 2, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@shanept

shanept commented Oct 2, 2018

Description
Upon LDAP errors, the PHP ldap extension may also return an error code. Using this code may provide a friendlier way to determine the root cause of an issue than to interpret the error message - consider how the following example may be achieved currently, with the LDAP component.

Example

$ldap = Ldap::create('ext_ldap', [...]);

try {
    $ldap->bind('invalid_user', 'invalid_password');
} catch (ConnectionException $ex) {
    switch ($ex->getCode()) {
        case INVALID_CREDENTIALS:
            $message = 'Invalid Username or Password.';
            break;
        case CONNECTION_TIMEOUT:
            $message = 'Unable to connect to server.';
            break;
        ...
    }
}
@scaytrase

This comment has been minimized.

Show comment
Hide comment
@scaytrase

scaytrase Oct 8, 2018

Contributor

I'd better suggest throw proper exception with given messages

Contributor

scaytrase commented Oct 8, 2018

I'd better suggest throw proper exception with given messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment