error.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # Copyright (C) 2008 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. class ManifestParseError(Exception):
  16. """Failed to parse the manifest file.
  17. """
  18. class ManifestInvalidRevisionError(Exception):
  19. """The revision value in a project is incorrect.
  20. """
  21. class NoManifestException(Exception):
  22. """The required manifest does not exist.
  23. """
  24. def __init__(self, path, reason):
  25. super(NoManifestException, self).__init__()
  26. self.path = path
  27. self.reason = reason
  28. def __str__(self):
  29. return self.reason
  30. class EditorError(Exception):
  31. """Unspecified error from the user's text editor.
  32. """
  33. def __init__(self, reason):
  34. super(EditorError, self).__init__()
  35. self.reason = reason
  36. def __str__(self):
  37. return self.reason
  38. class GitError(Exception):
  39. """Unspecified internal error from git.
  40. """
  41. def __init__(self, command):
  42. super(GitError, self).__init__()
  43. self.command = command
  44. def __str__(self):
  45. return self.command
  46. class UploadError(Exception):
  47. """A bundle upload to Gerrit did not succeed.
  48. """
  49. def __init__(self, reason):
  50. super(UploadError, self).__init__()
  51. self.reason = reason
  52. def __str__(self):
  53. return self.reason
  54. class DownloadError(Exception):
  55. """Cannot download a repository.
  56. """
  57. def __init__(self, reason):
  58. super(DownloadError, self).__init__()
  59. self.reason = reason
  60. def __str__(self):
  61. return self.reason
  62. class NoSuchProjectError(Exception):
  63. """A specified project does not exist in the work tree.
  64. """
  65. def __init__(self, name=None):
  66. super(NoSuchProjectError, self).__init__()
  67. self.name = name
  68. def __str__(self):
  69. if self.name is None:
  70. return 'in current directory'
  71. return self.name
  72. class InvalidProjectGroupsError(Exception):
  73. """A specified project is not suitable for the specified groups
  74. """
  75. def __init__(self, name=None):
  76. super(InvalidProjectGroupsError, self).__init__()
  77. self.name = name
  78. def __str__(self):
  79. if self.name is None:
  80. return 'in current directory'
  81. return self.name
  82. class RepoChangedException(Exception):
  83. """Thrown if 'repo sync' results in repo updating its internal
  84. repo or manifest repositories. In this special case we must
  85. use exec to re-execute repo with the new code and manifest.
  86. """
  87. def __init__(self, extra_args=None):
  88. super(RepoChangedException, self).__init__()
  89. self.extra_args = extra_args or []
  90. class HookError(Exception):
  91. """Thrown if a 'repo-hook' could not be run.
  92. The common case is that the file wasn't present when we tried to run it.
  93. """