Skip to content

Commit 578b0b7

Browse files
authored
Document the LDAPError fields
Also, correct the note on COMPARE_FALSE and COMPARE_TRUE python-ldap#355
1 parent d45ad6a commit 578b0b7

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

Doc/reference/ldap.rst

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -462,26 +462,27 @@ The module defines the following exceptions:
462462
are instead turned into exceptions, raised as soon an the error condition
463463
is detected.
464464

465-
The exceptions are accompanied by a dictionary possibly
466-
containing an string value for the key :py:const:`desc`
467-
(giving an English description of the error class)
468-
and/or a string value for the key :py:const:`info`
469-
(giving a string containing more information that the server may have sent).
470-
471-
A third possible field of this dictionary is :py:const:`matched` and
472-
is set to a truncated form of the name provided or alias dereferenced
473-
for the lowest entry (object or alias) that was matched.
474-
475-
The field :py:const:`msgid` is set in the dictionary where the
476-
exception can be associated with an asynchronous request.
477-
This can be used in asynchronous code where :py:meth:`result()` raises the
478-
result of an operation as an exception. For example, this is the case for
479-
:py:meth:`compare()`, always raises the boolean result as an exception
480-
(:py:exc:`COMPARE_TRUE` or :py:exc:`COMPARE_FALSE`).
481-
482-
Most exceptions from protocol results also carry the :py:attr:`errnum`
483-
attribute.
484-
465+
The exceptions are accompanied by a dictionary with additional information.
466+
All fields are optional and more fields may be added in the future.
467+
Currently, ``python-ldap`` may set the following fields:
468+
469+
* ``'result'``: a numeric code of the error class.
470+
* ``'desc'``: string giving a description of the error class, as provided
471+
by calling OpenLDAP's ``ldap_err2string`` on the ``result``.
472+
* ``'info'``: string containing more information that the server may
473+
have sent. The value is server-specific: for example, the OpenLDAP server
474+
may send different info messages than Active Directory or 389-DS.
475+
* ``'matched'``: truncated form of the name provided or alias.
476+
dereferenced for the lowest entry (object or alias) that was matched.
477+
* ``'msgid'``: ID of the matching asynchronous request.
478+
This can be used in asynchronous code where :py:meth:`result()` raises the
479+
result of an operation as an exception. For example, this is the case for
480+
:py:meth:`~LDAPObject.compare()`, always raises the boolean result as an
481+
exception (:py:exc:`COMPARE_TRUE` or :py:exc:`COMPARE_FALSE`).
482+
* ``'ctrls'``: list of :py:class:`ldap.controls.LDAPControl` instances
483+
attached to the error.
484+
* ``'errno'``: the C ``errno``, usually set by system calls or ``libc``
485+
rather than the LDAP libraries.
485486

486487
.. py:exception:: ADMINLIMIT_EXCEEDED
487488
@@ -515,14 +516,14 @@ The module defines the following exceptions:
515516
.. py:exception:: COMPARE_FALSE
516517
517518
A compare operation returned false.
518-
(This exception should never be seen because :py:meth:`compare()` returns
519-
a boolean result.)
519+
(This exception should only be seen asynchronous operations, because
520+
:py:meth:`~LDAPObject.compare_s()` returns a boolean result.)
520521

521522
.. py:exception:: COMPARE_TRUE
522523
523524
A compare operation returned true.
524-
(This exception should never be seen because :py:meth:`compare()` returns
525-
a boolean result.)
525+
(This exception should only be seen asynchronous operations, because
526+
:py:meth:`~LDAPObject.compare_s()` returns a boolean result.)
526527

527528
.. py:exception:: CONFIDENTIALITY_REQUIRED
528529

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy