exceptions.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2014 - Copyright Red Hat Inc
  4. Authors:
  5. Pierre-Yves Chibon <pingou@pingoured.fr>
  6. """
  7. from __future__ import absolute_import, unicode_literals
  8. class PagureException(Exception):
  9. """Parent class of all the exception for all Pagure specific
  10. exceptions.
  11. """
  12. pass
  13. class RepoExistsException(PagureException):
  14. """Exception thrown when trying to create a repository that already
  15. exists.
  16. """
  17. pass
  18. class ProjectBlackListedException(PagureException):
  19. """Exception thrown when trying to create a repository but, that repository
  20. name has been blacklisted
  21. """
  22. pass
  23. class AccessLevelNotFound(PagureException):
  24. """Exception raised when the access level asked is not allowed on pagure"""
  25. pass
  26. class FileNotFoundException(PagureException):
  27. """Exception thrown when the desired file is not found.
  28. This exception is found when the file is searched in a git repo or when
  29. setting up one of the git hook.
  30. """
  31. pass
  32. class APIError(PagureException):
  33. """Exception raised by the API when something goes wrong."""
  34. def __init__(self, status_code, error_code, error=None, errors=None):
  35. self.status_code = status_code
  36. self.error_code = error_code
  37. self.error = error
  38. self.errors = errors
  39. class BranchNotFoundException(PagureException):
  40. """Exception thrown when trying to use a branch that could not be
  41. found in a repository.
  42. """
  43. pass
  44. class PagureEvException(PagureException):
  45. """Exceptions used in the pagure_stream_server."""
  46. pass
  47. class GitConflictsException(PagureException):
  48. """Exception used when trying to pull on a repo and that leads to
  49. conflicts.
  50. """
  51. pass
  52. class HookInactiveException(PagureException):
  53. """Exception raised when the hook is inactive."""
  54. pass
  55. class NoCorrespondingPR(PagureException):
  56. """Exception raised when no pull-request is found with the given
  57. information."""
  58. pass
  59. class InvalidObjectException(PagureException):
  60. """Exception raised when a given object is not what was expected."""
  61. pass
  62. class PagureEncodingException(PagureException, ValueError):
  63. """Exception raised none of the encoding guessed could be applied to
  64. the content examined
  65. """
  66. pass
  67. class PagurePushDenied(PagureException):
  68. """Exception raised if a remote hook rejected a push"""
  69. pass
  70. class InvalidTimestampException(PagureException):
  71. """Exception raised when the hook is inactive."""
  72. pass
  73. class InvalidDateformatException(PagureException):
  74. """Exception raised when the hook is inactive."""
  75. pass