jwmu_exceptions.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # This file is part of jwmud, written by Helmut Pozimski in 2014.
  2. #
  3. # jwmud is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, version 2 of the License.
  6. #
  7. # jwmud is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with jwmud. If not, see <http://www.gnu.org/licenses/>.
  14. # -*- coding: utf8 -*-
  15. class DataBaseAccessFailed(Exception):
  16. """This exception will be raised when opening or creating the database
  17. failed.
  18. """
  19. def __init__(self):
  20. self.__message = "Accessing the database failed!"
  21. def __str__(self):
  22. return self.__message
  23. class DataBaseWriteFailed(Exception):
  24. """This exception will be raised when a write access to the database
  25. failed.
  26. """
  27. def __init__(self):
  28. self.__message = "Writing to the database failed, requested action " \
  29. "aborted !"
  30. def __str__(self):
  31. return self.__message
  32. class WrongParameters(Exception):
  33. """This exception will be raised when the number of parameters or their
  34. value is wrong.
  35. """
  36. def __init__(self):
  37. self.__message = "The wrong number or values of parameters where " \
  38. "given to the function, the requested action failed."
  39. def __str__(self):
  40. return self.__message
  41. class CategoryNotFound(Exception):
  42. """This exception will be raised when the user tries to access a category
  43. that does not exist in the database.
  44. """
  45. def __init__(self):
  46. self.__message = "The category could not be found in the database."
  47. def __str__(self):
  48. return self.__message
  49. class DayAlreadyInDatabase(Exception):
  50. """This exception will be raised when the user tries to add a day to the
  51. database which does already have an entry there.
  52. """
  53. def __init__(self):
  54. self.__message = "This day already exists in the database."
  55. def __str__(self):
  56. return self.__message
  57. class ConfigurationFileMissing(Exception):
  58. """This exception will be raised when the configuration file is
  59. missing.
  60. """
  61. def __init__(self):
  62. self.__message = "The configuration file does not exist."
  63. def __str__(self):
  64. return self.__message
  65. class ConfigurationFileAccessDenied(Exception):
  66. """This exception will be raised when the access to the configuration
  67. file is denied by it's permissions.
  68. """
  69. def __init__(self):
  70. self.__message = "The configuration file could not be opened " \
  71. "for reading."
  72. def __str__(self):
  73. return self.__message
  74. class PasswdOrGroupAccessFailed(Exception):
  75. """This exception will be raised when accessing either /etc/passwd or
  76. /etc/group failed.
  77. """
  78. def __init__(self):
  79. self.__message = "Opening /etc/passwd or /etc/group failed."
  80. def __str__(self):
  81. return self.__message
  82. class DaemonAlreadyRunning(Exception):
  83. """This exception will be raised when another process is already
  84. running.
  85. """
  86. def __init__(self):
  87. self.__message = "Another process is already running, exiting."
  88. def __str__(self):
  89. return self.__message
  90. class WritingPIDFileFailed(Exception):
  91. """This exception will be raised when creating the PID file failed."""
  92. def __init__(self):
  93. self.__message = "The PID file could not be created, please check if " \
  94. "/run or /var/run exist and are writable."
  95. def __str__(self):
  96. return self.__message