|
| 1 | +:mod:`getdns` exceptions |
| 2 | +============================= |
| 3 | + |
| 4 | +.. module:: getdns |
| 5 | + :synopsis: getdns exception description and explanation |
| 6 | +.. sectionauthor:: Melinda Shore <[email protected]> |
| 7 | + |
| 8 | + |
| 9 | +getdns exceptions |
| 10 | +----------------- |
| 11 | + |
| 12 | +.. py:exception:: getdns.error |
| 13 | +
|
| 14 | + getdns will throw an exception, ``getdns.error``, under |
| 15 | + certain conditions. Those conditions include: |
| 16 | + |
| 17 | + * a required parameter having a bad value |
| 18 | + * a badly-formed domain name in the query |
| 19 | + * a bad ``Context()`` object |
| 20 | + * a failed ``Context()`` update |
| 21 | + * an out-of-bounds error for a getdns data structure |
| 22 | + * requesting an extension that doesn't exist |
| 23 | + * requesting DNSSEC validation while using stub |
| 24 | + resolution |
| 25 | + |
| 26 | +Please note that a successful return from a getdns method |
| 27 | +does `not` indicate that the query returned the records |
| 28 | +being requested, but rather that the query is formed |
| 29 | +correctly and has been submitted to the DNS. A getdns |
| 30 | +exception is typically the result of a coding error. |
| 31 | + |
| 32 | +getdns will set the exception message to a diagnostic |
| 33 | +string, which may be examined for help in resolving the |
| 34 | +error. |
| 35 | + |
| 36 | +Example |
| 37 | +------- |
| 38 | + |
| 39 | +:: |
| 40 | + |
| 41 | + import getdns, sys |
| 42 | + |
| 43 | + c = getdns.Context() |
| 44 | + try: |
| 45 | + results = c.address('www.example.com', foo='bar') |
| 46 | + except getdns.error, e: |
| 47 | + print(str(e)) |
| 48 | + sys.exit(1) |
| 49 | + |
| 50 | + |
| 51 | +This will result in "A required parameter had an invalid |
| 52 | +value" being printed to the screen. |
0 commit comments