PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/chrono/error.py

https://bitbucket.org/erikg/python-chrono
Python | 111 lines | 36 code | 25 blank | 50 comment | 0 complexity | 84a9fcf54ec4cde1cca41864743a6f45 MD5 | raw file
Possible License(s): GPL-3.0
  1. # -*- coding: utf-8 -*-
  2. #
  3. # python-chrono - a Python module for easy and convenient date/time handling
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. """
  19. This module contains various exceptions used by python-chrono.
  20. .. note::
  21. These exceptions are imported into the main :mod:`chrono` module,
  22. and can therefore be referenced both via (for example)
  23. :class:`chrono.error.YearError` and :class:`chrono.YearError`.
  24. The exception tree is structured as follows:
  25. * :class:`Exception`
  26. * :class:`chrono.error.NoDateTimeError`
  27. * :class:`ValueError`
  28. * :class:`chrono.error.DateTimeError`
  29. * :class:`chrono.error.DateError`
  30. * :class:`chrono.error.DayError`
  31. * :class:`chrono.error.MonthError`
  32. * :class:`chrono.error.WeekError`
  33. * :class:`chrono.error.YearError`
  34. * :class:`chrono.error.TimeError`
  35. * :class:`chrono.error.HourError`
  36. * :class:`chrono.error.MinuteError`
  37. * :class:`chrono.error.SecondError`
  38. * :class:`chrono.error.ParseError`
  39. """
  40. class DateTimeError(ValueError):
  41. "Error for invalid date and/or time."
  42. pass
  43. class DateError(DateTimeError):
  44. "Error for invalid date."
  45. pass
  46. class YearError(DateError):
  47. "Error for invalid year."
  48. pass
  49. class MonthError(DateError):
  50. "Error for invalid month."
  51. pass
  52. class WeekError(DateError):
  53. "Error for invalid week."
  54. pass
  55. class DayError(DateError):
  56. "Error for invalid day."
  57. pass
  58. class TimeError(DateTimeError):
  59. "Error for invalid time."
  60. pass
  61. class HourError(TimeError):
  62. "Error for invalid hour."
  63. pass
  64. class MinuteError(TimeError):
  65. "Error for invalid minute."
  66. pass
  67. class SecondError(TimeError):
  68. "Error for invalid second."
  69. pass
  70. class NoDateTimeError(Exception):
  71. "Error for missing date/time data."
  72. pass
  73. class ParseError(ValueError):
  74. "Error for parse failures."
  75. pass