error.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # -*- test-case-name: twisted.names.test -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Exception class definitions for Twisted Names.
  6. """
  7. from __future__ import division, absolute_import
  8. from twisted.internet.defer import TimeoutError
  9. class DomainError(ValueError):
  10. """
  11. Indicates a lookup failed because there were no records matching the given
  12. C{name, class, type} triple.
  13. """
  14. class AuthoritativeDomainError(ValueError):
  15. """
  16. Indicates a lookup failed for a name for which this server is authoritative
  17. because there were no records matching the given C{name, class, type}
  18. triple.
  19. """
  20. class DNSQueryTimeoutError(TimeoutError):
  21. """
  22. Indicates a lookup failed due to a timeout.
  23. @ivar id: The id of the message which timed out.
  24. """
  25. def __init__(self, id):
  26. TimeoutError.__init__(self)
  27. self.id = id
  28. class DNSFormatError(DomainError):
  29. """
  30. Indicates a query failed with a result of C{twisted.names.dns.EFORMAT}.
  31. """
  32. class DNSServerError(DomainError):
  33. """
  34. Indicates a query failed with a result of C{twisted.names.dns.ESERVER}.
  35. """
  36. class DNSNameError(DomainError):
  37. """
  38. Indicates a query failed with a result of C{twisted.names.dns.ENAME}.
  39. """
  40. class DNSNotImplementedError(DomainError):
  41. """
  42. Indicates a query failed with a result of C{twisted.names.dns.ENOTIMP}.
  43. """
  44. class DNSQueryRefusedError(DomainError):
  45. """
  46. Indicates a query failed with a result of C{twisted.names.dns.EREFUSED}.
  47. """
  48. class DNSUnknownError(DomainError):
  49. """
  50. Indicates a query failed with an unknown result.
  51. """
  52. class ResolverError(Exception):
  53. """
  54. Indicates a query failed because of a decision made by the local
  55. resolver object.
  56. """
  57. __all__ = [
  58. 'DomainError', 'AuthoritativeDomainError', 'DNSQueryTimeoutError',
  59. 'DNSFormatError', 'DNSServerError', 'DNSNameError',
  60. 'DNSNotImplementedError', 'DNSQueryRefusedError',
  61. 'DNSUnknownError', 'ResolverError']